This question is fairly short and to the point, basically I just need help with what string pattern I should be using here. I'm trying to make a function that will get all string in a text, except anything in cased in two bracket symbols ("[" , "]"). Here's my attempt:
local String = "This is a [ignored string] string that ignores [ignored again] certain blocks of text."
local function DecodeStr(Source)
local new = ""
for i in string.gmatch(Source, "[^%[.-%]]+") do
new = new .. i
end
return new
end
print(DecodeStr(String))
Problem
The code above should ignore all blocks of text in between the brackets, and including the brackets, but instead just returns text without brackets (not ignoring the text inside them as well).
Is there any string pattern that could fix this so the result would look something like:
"This is a string that ignores certain blocks of text"
From the example above?

1 comment
Thank you!