lundi 14 mai 2018

Lua Pattern: %b{}? optional balanced braces possible

I want to have optional balanced braces to be part of my match. Is that possible with just the normal patterns? My Test Code looks like this:

for m in string.match('str{},str2{str3{}},str4,str5{a{}b{}}', '[^,]-%b{}') do
  print(v)
end

the output is:

str{}
str2{str3{}}
str5{a{}b{}}

the missing part is str4

I thought the pattern [^,]-%b{}? would do it but %bxy and ? are both pattern items so of course it does not work, but is there a way to do it anyway?

Aucun commentaire:

Enregistrer un commentaire