| Pattern | Description |
|---|---|
| ^ | Start of line |
| $ | End of line |
| \b | Word boundary |
| \B | Non-word boundary |
| \< | Start of word (GNU) |
| \> | End of word (GNU) |
| Pattern | Description |
|---|---|
| . | Any single character (except newline) |
| [abc] | One of a, b, or c |
| [^abc] | Any character except a, b, or c |
| [a-z] | Any lowercase letter |
| [A-Z] | Any uppercase letter |
| [0-9] | Any digit |
| [a-zA-Z0-9] | Any alphanumeric character |
| \d | Any digit, same as [0-9] (PCRE only) |
| \D | Any non-digit (PCRE only) |
| \w | Any word character (letter, digit, underscore) |
| \W | Any non-word character |
| \s | Any whitespace (space, tab, newline) |
| \S | Any non-whitespace character |
| Class | Description |
|---|---|
| [[:alpha:]] | Alphabetic characters |
| [[:digit:]] | Digits (0-9) |
| [[:alnum:]] | Alphanumeric characters |
| [[:space:]] | Whitespace characters |
| [[:upper:]] | Uppercase letters |
| [[:lower:]] | Lowercase letters |
| [[:punct:]] | Punctuation characters |
| [[:print:]] | Printable characters |
| [[:blank:]] | Space and tab |
| [[:xdigit:]] | Hexadecimal digits |
| Pattern | Description |
|---|---|
| * | Zero or more times |
| + | One or more times |
| ? | Zero or one time |
| {n} | Exactly n times |
| {n,} | n or more times |
| {n,m} | Between n and m times |
| Pattern | Description |
|---|---|
| (abc) | Group: match "abc" as a unit |
| a|b | Alternation: match a or b |
| \1 | Backreference: match the first captured group again |
| \2 | Backreference: match the second captured group |
| Pattern | Description |
|---|---|
| (?=x) | Lookahead: followed by x |
| (?!x) | Negative lookahead: not followed by x |
| (?<=x) | Lookbehind: preceded by x |
| (?<!x) | Negative lookbehind: not preceded by x |
| *? +? | Lazy quantifier: match as little as possible |