This article shows how to use the
string.rxsub() functions with PCRE regex, these functions are the equivalent of
string.gsub(), but using PCRE regex instead of the simpler Lua pattern matching. There are also some (hopefully) helpful PCRE regex examples, including some useful features (that are not available with Lua pattern matching).
All regex patterns used in this article are listed on the PCRE Samples page, including links to any examples on the
To find out more you can follow the More Information links below or do a quick web search (“PCRE”, “PCRE regex”, “PCRE tutorial”).
Tip: I found the Regex 101 online tester very helpful when creating/testing the expressions on this page. The Regex Buddy application (Windows only) also comes highly recommended, though it is not free. And you can google to find other regex testers.