Regular expressions
๐ฎ๐ง๐๐๐ฉ๐ค๐ผ ๐ฆ๐๐๐๐ฎ๐ง๐๐ฉ๐ฏ๐
Regular expressions, or regex for short, are a means of finding, replacing, validating, and semantically identifying phrases within plain text.
They're a core part of the Unix toolset, implemented in standard Unix utilities such as ed, sed, grep, ex, and vi; programming languages such as awk and Perl; and server software modules such as Apache's mod_rewrite and Nginx's ngx_http_rewrite_module.
As is often the case when threatened with the possibility of a single useful standard, different engineers blessed us with competing variations, including BREs, EREs, and PCREs. It's therefore important to check which variation you're using before you get too far writing an especially complex regular expression.
Contrast with the much simpler wildcards, as used at the command line to refer to multiple files at once.
See also
Further reading
Deep dives
- Mastering Regular Expressions Jeffrey Friedl, 1997, ISBN 1-56592-257-3
- Mastering Regular Expressions, Second Edition Jeffrey Friedl, 2002, ISBN 0-596-00289-0
Pattern matching syntaxes: Regular expressions