Pattern matching 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 " ) . " Regexes " ( patterns ) in Lua . Lua has a few string functions that use patterns ( what some people mistakenly call regexes ) . Among them are Constructing a pattern . So , how do we construct a pattern ? At the foundation of patterns are character classes . These classes represent sets of characters . Lua ' s classes are The upper cased version of the above reverses the meaning of said ( i . e . % A - - - represents all " non " - letters ) . All patterns are made up of a sequence of these classes . For example , if you wanted to match the string " # # # Abc " ( # designates a digit ) , you would use the pattern " % d % d % dAbc " . By adding modifiers , you can change the meaning of these classes . Let x be the class we want to modify . There are also four special pattern elements When ^ or $ is anywhere else in a pattern , it has no special meaning . Patterns may also have subpatterns . These are enclosed with ( ) and are counted as matches are found . They can be accessed using the % n element mentioned above . Using the empty capture " ( ) " will return the string position where a match is found . Source Example . Say we ' re writing a function that watches the combat chat and counts the number of times a murloc dies nearby ( don ' t we all want this ? : ) ) . So , how do we do this ? ( incidentally , I have done this . It was quite satisfying ) For simplicity ' s sake , let ' s assume all murlocs have the word " Murloc " in their name . For this case , the pattern " Murloc " would be all we need . However , as we all know , there seem to be no end to the varieties of Murlocs . Say we want to count all the murlocs killed nearby while we ' re in Darkshore . Now matching each type by name exactly would work , but would result in a huge function . It becomes simpler when we notice that they all ( save the named ones ) are of the " Greymist " clan , as we can use " Greymist " as our pattern . Now these are extremely simple patterns . For a better challenge , let ' s go one step further . Instead of just counting the number that die , let ' s replace the name of whatever died with " An unholy demon spawn " . Since the name of the mob will vary , we need a pattern that will match all of them . To do this , we can use " ^ Greymist . * dies ( ) " . This pattern will match strings that start with the word " Greymist " followed by any number of characters followed by the word " dies " . Then we can just use the string . gsub function to do the replacement like so : string . gsub ( chatstring , " ^ Greymist . * dies " , " An unholy demon spawn dies " ) ; Afterthoughts . Hopefully this has given you a good start into how to use regular expressions . There are many many resources online regarding them , and if there ' s anything not covered here , you should be able to find it somewhere out there . External links . Regular Expressions Explained - Good introduction to regexes Lua . org - Good manual Lua - users . org - Wiki