Back to Learn
Published: June 2026•By Web Util Slyce Team
Regex Guide & Patterns
A comprehensive regular expression reference. Test any pattern interactively with our Regex Tester.
Anchors
| Pattern | Description |
|---|---|
| ^ | Start of string (or line in multiline mode) |
| $ | End of string (or line in multiline mode) |
| \b | Word boundary |
| \B | Not a word boundary |
Character Classes
| Pattern | Description |
|---|---|
| . | Any single character (except newline with /m) |
| \d | Digit [0-9] |
| \D | Non-digit [^0-9] |
| \w | Word character [a-zA-Z0-9_] |
| \W | Non-word character |
| \s | Whitespace (space, tab, newline) |
| \S | Non-whitespace |
| [abc] | Any character in the set |
| [^abc] | Any character NOT in the set |
| [a-z] | Range of characters |
Quantifiers
| Pattern | Description |
|---|---|
| * | Zero or more (greedy) |
| + | One or more (greedy) |
| ? | Zero or one (optional) |
| {n} | Exactly n times |
| {n,} | n or more times |
| {n,m} | Between n and m times |
| *? | Zero or more (lazy/non-greedy) |
| +? | One or more (lazy/non-greedy) |
Groups & Alternation
| Pattern | Description |
|---|---|
| (...) | Capturing group (creates a backreference) |
| (?:...) | Non-capturing group |
| (?=...) | Positive lookahead |
| (?!...) | Negative lookahead |
| (?<=...) | Positive lookbehind |
| (?<!...) | Negative lookbehind |
| | | Alternation (OR) |
| \1 | Backreference to group 1 |
Escape Sequences
| Pattern | Description |
|---|---|
| \ | Escape special character |
| \t | Tab |
| \n | Newline (line feed) |
| \r | Carriage return |
| \0 | Null character |
| \xhh | Character by hex code (e.g., \x20 for space) |
Flags Reference
/gGlobal: Find all matches, not just the first
/iCase-Insensitive: Ignore case when matching
/mMultiline: ^ and $ match line start/end
/sDotall: '.' matches newlines
/uUnicode: Unicode-aware matching
/ySticky: Match from lastIndex position