| Any single character except a line break. | a.c→abc, a-c |
| Any digit from 0 to 9. | \d\d→42 |
| Any character that is not a digit. | \D+→abc |
| A word character: ASCII letter, digit, or underscore. | \w+→user_42 |
| Any character that is not a word character. | \W→@ |
| Any whitespace: space, tab, or line break. | a\sb→a b |
| Any character that is not whitespace. | \S+→hello |
| Any one of the characters inside the brackets. | gr[ae]y→gray, grey |
| Any character except those inside the brackets. | [^0-9]+→abc |
| Any character in the given range. | [0-9A-F]+→1F4 |
| Any Unicode letter in any script (needs the u flag). | \p{L}+→café |
| A backslash makes a special character literal, here a dot. | \$\d+→$5 |
| Start of the string, or of each line with the m flag. | ^Hi→Hi there |
| End of the string, or of each line with the m flag. | end$→the end |
| Position between a word character and a non-word character. | \bcat\b→cat |
| Position that is not a word boundary. | \Bcat→concat |
| Zero or more of the previous item. | ab*c→ac, abbc |
| One or more of the previous item. | ab+c→abc, abbc |
| Zero or one of the previous item (makes it optional). | colou?r→color, colour |
| Exactly n of the previous item. | \d{4}→2026 |
| Between n and m of the previous item. | \d{2,4}→12, 1234 |
| n or more of the previous item. | a{2,}→aa, aaaa |
| Lazy quantifier: matches as few characters as possible. | <.+?>→<b> |
| Capturing group: groups tokens and remembers the match. | (\d+)-(\d+)→10-20 |
| Groups tokens without remembering the match. | (?:ab)+→abab |
| Capturing group you can refer to by name. | (?<year>\d{4})→2026 |
| Matches the same text that group 1 matched. | (\w)\1→ll |
| Matches either the left or the right side. | cat|dog→cat, dog |
| Position followed by the pattern, without consuming it. | \d+(?=%)→50% |
| Position not followed by the pattern. | \d+(?!px)→12em |
| Position preceded by the pattern, without consuming it. | (?<=\$)\d+→$99 |
| Position not preceded by the pattern. | (?<!-)\d+→7 |
| Global: find all matches instead of only the first. | /a/g→a, a, a |
| Ignore case: uppercase and lowercase match each other. | /hello/i→HeLLo |
| Multiline: ^ and $ match at the start and end of every line. | /^\w+/m→line starts |
| Dot-all: the dot also matches line breaks. | /a.b/s→a\nb |
| Unicode: enables \p{…} and full Unicode code points. | /\p{Emoji}/u→🎉 |
| Sticky: matches only at the current lastIndex position. | /foo/y→lastIndex |