meta data for this page
  •  

This is an old revision of the document!


http://www.lua.org/manual/5.1/manual.html#5.4.1

escape special characters for pattern matching

pattern = pattern:gsub ("%+", "%%%+") -- change '+' to '%+'
pattern = pattern:gsub("([+%?])", "%%%1") -- escape only characters from set
pattern = pattern:gsub("([^%w])", "%%%1") -- escape all non alphanumeric characters