Lua: How to get string captures containing a specific substring? -


in lua, in want captures string containing specific substring. e.g. in string

 test = "<item>foo</item>  <item>bar</item>" 

i want items containing "a", in case "bar". tried this:

print(string.find(test, "<item>(.-a.-)</item>")) 

but result is:

1   34  foo</item>  <item>bar 

so .- more greedy expected. correct pattern?

try print(string.find(test, "<item>([^<]-a.-)</item>")).


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -