The supported meta characters are:
. | Match any character but newline. |
\ | Quote the next metacharacter. |
^ | Match the beginning of the line. |
$ | Match the end of the line (or before newline at the end). |
| | Alternation. |
() | Grouping. |
[] | Character class. |
The following standard escapes are recognized:
\a | Bell. |
\e | Escape. |
\f | Form-feed. |
\n | Newline. |
\r | Carriage-return. |
\t | Tab. |
The following Perl-defined zero-width assertions are supported:
\A | Match only at beginning of string. |
\b | Match a word boundary. |
\B | Match a non-word boundary. |
\z | Match only at end of string. |
\Z | Match only at end of string, or before newline at the end. |
The following standard character classes are recognized:
\d | Digit. |
\D | Non-digit. |
\s | Whitespace. |
\S | Non-whitespace. |
\w | Word: [A-Za-z0-9_]. |
\W | Non-word. |
The following standard quantifiers are recognized:
* | Match 0 or more times. |
+ | Match 1 or more times. |
? | Match 1 or 0 times. |
{ n } | Match exactly n times. |
{ n,} | Match at least n times. |
{ n, m } | Match at least n but not more than m times. |
Back References
Back-references like \1 match whatever the corresponding group (parenthesized regular expression component) matched. For example the regular expression
./^(.+)\1$/
matches repeated strings like
xyzxyz abab
Allen’s comments also document support for:
\033 | Octal char. |
\x1B | Hex char. |
\x { 263a } | Wide hex char. (Unicode SMILEY) |
\c[ | Control char. |
\L | Lowercase until \E. (Think vi.) |
\U | Uppercase until \E. (Think vi.) |
\E | End case modification. (Think vi.) |
\Q | Quote (disable) pattern metacharacters until next \E. |
\pP | Match P, named property. Use \p { Prop } for longer names. |
\PP | Match non-P. |
\C | Match a single C char (octet) even under utf8. |
Code comments document the following as implemented by the parser but not by the regular expression engine proper:
\N { name } | Named char. |
\l | Lowercase next char. (Think vi.) |
\u | Uppercase next char. (Think vi.) |
There is currently no locale support — feel free to contribute this!