Hello. I’m trying to make my own plugin, but for it I need filter my string correctly. But I have 1 little problem - I can’t understand what means this 2 string patterns:
Can someone explain me, when I should use them?
Hello. I’m trying to make my own plugin, but for it I need filter my string correctly. But I have 1 little problem - I can’t understand what means this 2 string patterns:
local String = "Hello (John Doe) world!"
local Name = string.match(String, "%b()")
print(Name) --'(John Doe)'.
Name = string.gsub(String, "^%a+%s%((%a+%s%a+)%)%s%a+!$", "%1")
print(Name) --'John Doe'.
%bxy
captures everything from the first character ‘x’ to the last character ‘y’ and everything in between.
%n
represents the nth capture group.