WoW:Pattern matching: Difference between revisions

m
Move page script moved page Pattern matching to WoW:Pattern matching without leaving a redirect
m (→‎Constructing a pattern: I don't know how that little caveat was missed.)
m (Move page script moved page Pattern matching to WoW:Pattern matching without leaving a redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{wowlua}}
A '''regular expression''' is a formula for matching strings that follow some pattern. The formula (and syntax used) varies depending on the method of searching used. [[Lua]], the scripting language that World of Warcraft uses, does not support regular expressions. Instead, it offers a basic pattern-matching mechanism with most of the features of REs. Though since Lua doesn't implement regexes, at all, but rather "patterns", this can confuse more than it helps.  Better refer to the official Lua documentation (which never mentions "regular expressions").
A '''regular expression''' is a formula for matching strings that follow some pattern. The formula (and syntax used) varies depending on the method of searching used. [[Lua]], the scripting language that World of Warcraft uses, does not support regular expressions. Instead, it offers a basic pattern-matching mechanism with most of the features of REs. Though since Lua doesn't implement regexes, at all, but rather "patterns", this can confuse more than it helps.  Better refer to the official Lua documentation (which never mentions "regular expressions").


Line 7: Line 8:
* [[API_strfind|string.find]](string, pattern) -- finds the first instance of pattern in string
* [[API_strfind|string.find]](string, pattern) -- finds the first instance of pattern in string
* string.gfind(string, pattern) -- when called repeatedly, finds each successive instance of pattern in string
* string.gfind(string, pattern) -- when called repeatedly, finds each successive instance of pattern in string
* [[API gsub|string.gsub]](string, pattern, repl) -- returns a string where all instances of pattern in string have been replaced with repl
* [[API gsub|string.gmatch]](string, pattern, repl) -- returns a string where all instances of pattern in string have been replaced with repl
* [[API strmatch|string.match]](string, pattern, init) -- Returns a list of matches of pattern in string, starting search at init (1 is the first character of string, 2 is the second, etc.).
* [[API strmatch|string.match]](string, pattern, init) -- Returns a list of matches of pattern in string, starting search at init (1 is the first character of string, 2 is the second, etc.).


Line 75: Line 76:
[http://www.lua.org/manual/5.0/manual.html#5.3 Lua.org] - Good manual
[http://www.lua.org/manual/5.0/manual.html#5.3 Lua.org] - Good manual
[http://lua-users.org/wiki/PatternsTutorial Lua-users.org] - Wiki
[http://lua-users.org/wiki/PatternsTutorial Lua-users.org] - Wiki
[[Category:Glossary]]
[[Category:Glossary]]
[[Category:HOWTOs]]
[[Category:HOWTOs]]
[[Category:Lua]]
Anonymous user