The string.find
method provides an optional 4th parameter to enforce a plaintext search by itself.
For example:
string.find("he#.*o", "e#.*o", 1, true)
will give you the correct results.
Quoting the Lua manual pages:
string.find (s, pattern [, init [, plain]])
A value of
true
as a fourth, optional argumentplain
turns off the pattern matching facilities, so the function does a plain "find substring" operation, with no characters in pattern being considered magic. Note that ifplain
is given, theninit
must be given as well.