For example, I have this line of code:
print(string.match("test!/Uglypoe","%w+"))
This would print only "test". How could I change it so that it would get all alphanumeric characters (%w+) as well as certain characters (such as !, ?, and /).
This isn't really a LUA question and more of a regex question. I would encourage you to read up on regular expressions. However, I will help you with your question. I really don't understand what you're trying to match in your string, but if you want to match alphanumeric, you would use [a-zA-Z0-9]
. If you want to match the characters !?/
, you would use [\!\?\/]
.
Example usage: You want to find an alphanumeric string between two characters that are either !
or ?
or /
, in the format !teststring1!
The regex to match this would be ([\!\?\/])[a-zA-Z0-9]+\1