I'm trying to match and return a string between two (or one if there's no closing character, then until the string's end) character.
local id = "+@a-@s,@n";
local addOperator = string.match(id, "^[+](.+)(?[-])"); -- should return "@a"
if (addOperator) then
-- ...
end
local removeOperator = string.match(id, "^[-](.+)(?[+])"); -- should return "@s,@n"
if (removeOperator) then
-- ...
end
-- Or without the excluding operator "-"
local id = "+@a";
local addOperator = string.match(id, "^[+](.+)(?[-])"); -- should return "@a", with my pattern it returns a nil.
if (addOperator) then
-- ...
end