. | Any character except a line break (with the s flag, line breaks count too). |
\d | A digit from 0 to 9. |
\D | Anything that is not a digit. |
\w | A letter, digit, or underscore _ (a “word”). |
\W | The opposite of \w. |
\s | Whitespace: space, tab, or line break. |
\S | Anything that is not whitespace. |
\t | Tab. |
\n | Line break. |
\b | Word boundary (between a letter/digit and something else). |
\B | A position that is not a word boundary. |
^ | Start of the text (with the m flag, the start of each line). |
$ | End of the text (with the m flag, the end of each line). |
? | The previous item is optional: it appears 0 or 1 time. |
* | The previous item may repeat 0 or more times. |
+ | The previous item may repeat 1 or more times. |
{n} | The previous item appears exactly n times. |
{n,} | The previous item appears n times or more. |
{n,m} | The previous item appears from n to m times. |
| | Or: matches the left side or the right side. |
() | Group: treats several items as one and keeps the matched text. |
(?: ) | Group that does not keep the text (grouping only). |
[abc] | One character among a, b, or c. |
[^abc] | A character that is not a, b, or c. |
[a-z] | A lowercase letter from a to z. |
\ | Escapes the next symbol so it is taken literally (for example \. is an actual dot). |
(?= ) | Lookahead: matches only if what comes after matches, without consuming that text. |
(?! ) | Negative lookahead: matches only if what follows does not match. |
(?<= ) | Lookbehind: matches only if what came before match. |
(?<! ) | Negative lookbehind: matches only if what came before does not match. |