I'm looking for a way search in a string for a very specific set of characters: "(),:;<>@[\]
specialChar = str:find("[\"][%(][%)][,][:][;][<][>][@][%[][%]][\\]")
I'm thinking that there will be no pattern to satisfy my need because of the Limitations of Lua patterns.
I have read the Lua Manual pattern matching section pretty thoroughly but still can't seem to figure it out.
Does anyone know a way I can identify if a given string contains any of these characters?
Note, I do not need to know anything about which character or where in the string it is, if that helps.
To check if a string contains "
, (
, )
, ,
, :
, ;
, <
, >
, @
, [
, \
or ]
you may use
function ContainsSpecialChar(input)
return string.find(input, "[\"(),:;<>@[\\%]]")
end
See the Lua demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With