Tip of the day: Check out Special users on how to give trusted users/bots more rights without making them IRCOp.

Introduction to regex (PCRE)

From UnrealIRCd documentation wiki
Jump to navigation Jump to search

Regex is a powerful tool, but it will take time and effort to learn. Once you have learned it, though, it will be useful in many situations. It is very powerful for spamfilters but regex is also used in other software so you won't be learning it just for UnrealIRCd. UnrealIRCd uses the PCRE2 regex engine, this is the same regex engine as used in PHP and is compatible with Perl regex. This is the most popular regex flavor.

In UnrealIRCd you don't use slashes at the beginning or start of the regex. So don't use /word/. You simply use word.

An excellent introduction to regex, that explains regex step-by-step, is at http://regular-expressions.info/

There is also https://regex101.com/ which allows you test regex easily via their webinterface. UnrealIRCd uses the PCRE2 syntax, which that site uses by default.

The complete PCRE2 regex reference specification is in https://www.pcre.org/current/doc/html/pcre2pattern.html but is rather technical.