So my goal is to be able to use the %b()
pattern to get the text between brackets within a string. However, I also need it to ignore any brackets that are inside quotes in that string, and not count them as extra opening/closing brackets. For example:
local str = [[(one(two("three")))]] print(str:match("%b()")) --> (one(two("three")))
will print normally. But then, if a bracket is added within the quotes in the string, it treats it as a closing bracket, only printing two closing brackets at the end of the string when there should be three:
local str = [[(one(two("thr)ee")))]] print(str:match("%b()")) --> (one(two("thr)ee"))
Any ideas on how to go about ignoring brackets within quotes in the string?
Try formatting the string using the ' ' marks, like this?
local str = '(one(two("thr)ee")))'