meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lua:patterns [2015/10/20 14:35] – created niziakprogramming:lua:patterns [2020/07/03 09:48] (current) – ↷ Page moved from lua:patterns to programming:lua:patterns niziak
Line 1: Line 1:
 [[http://www.lua.org/manual/5.1/manual.html#5.4.1]] [[http://www.lua.org/manual/5.1/manual.html#5.4.1]]
 +[[https://www.gammon.com.au/scripts/doc.php?lua=string.find]]
  
 +=== escape special characters for pattern matching === 
 +<code lua> 
 +pattern = pattern:gsub ("%+", "%%%+") -- change '+' to '%+' 
 +pattern = pattern:gsub("([+%?])", "%%%1") -- escape only characters from set 
 +pattern = pattern:gsub("([^%w])", "%%%1") -- escape all non alphanumeric characters 
 +</code>