Regular expressions / Lua patterns / LPEG

Posted by Nick Gammon on Fri 07 Oct 2016 12:08 AM — 1 posts, 6,953 views.

Australia Forum Administrator #0
I have written a fairly lengthy discussion about:

  • PCRE regular expressions (such as are used in triggers)
  • Lua patterns (as used in Lua string.find and string.match)
  • LPEG grammars (which can be used in Lua)


This can be found at: http://www.gammon.com.au/mushclient/LPEG.htm

There is also a shortcut at: http://www.gammon.com.au/lpeg

That pages compares and contrasts the various techniques you can use to parse strings and extract data from them. This is useful in situations like parsing incoming text from the MUD, or in some cases fiddling with incoming packets to do things like extract or alter colour coding.