| . | Any character except a line break (any at all with the s flag) | a.c matches abc, a c |
| \d \D | A digit / a non-digit | \d+ matches 123 in abc 123 |
| \w \W | A word character [A-Za-z0-9_] / a non-word character | \w+ matches hello_1 |
| \s \S | Whitespace / non-whitespace | \s+ matches runs of spaces and tabs |
| [abc] | One character from the set | [aeiou] matches any vowel |
| [^abc] | One character NOT in the set | [^0-9] matches any non-digit |
| [a-z] | One character in the range | [a-f0-9] matches one hex digit |
| * | Zero or more of the preceding item | a* matches '', a, aaa |
| + | One or more of the preceding item | \d+ never matches empty text |
| ? | Zero or one — makes the preceding item optional | colou?r matches color and colour |
| {n} / {n,} / {n,m} | Exactly n / at least n / between n and m repetitions | \d{4} matches a 4-digit year |
| *? +? ?? | Lazy versions — match as little as possible | <.+?> stops at the first > |
| ^ $ | Start / end of the string (of each line with the m flag) | ^\d+$ — the whole text is digits |
| \b | A word boundary — between a \w and a \W position | \bcat\b does not match inside cats |
| ( … ) | Capturing group — its substring is reported as a group | (\d+)-(\d+) on 2026-11: groups 2026, 11 |
| (?: … ) | Non-capturing group — groups without reporting | (?:ab)+ matches abab, no groups |
| (?<name> … ) | Named capturing group | (?<year>\d{4}) names the year group |
| a|b | Alternation — match a or b | cat|dog matches either word |
| \. | A literal dot (backslash escapes any special character) | 1\.5 matches 1.5, not 145 |