Regex Playground
Live regex tester with match highlighting, capture group explorer, and pattern library
/
/
Click to replace · Shift+click to append
Character Classes
| . | Any character except newline (use s flag for newline too) |
| \w | Word character: [a-zA-Z0-9_] |
| \W | Non-word character |
| \d | Digit: [0-9] |
| \D | Non-digit |
| \s | Whitespace: space, tab, newline, etc. |
| \S | Non-whitespace |
| [abc] | Character set — matches a, b, or c |
| [^abc] | Negated set — anything except a, b, c |
| [a-z] | Range — any lowercase letter |
Anchors
| ^ | Start of string (or line with m flag) |
| $ | End of string (or line with m flag) |
| \b | Word boundary |
| \B | Non-word boundary |
Quantifiers
| * | 0 or more (greedy) |
| + | 1 or more (greedy) |
| ? | 0 or 1 — makes preceding token optional |
| *? | 0 or more (lazy — matches as few as possible) |
| +? | 1 or more (lazy) |
| {n} | Exactly n times |
| {n,} | n or more times |
| {n,m} | Between n and m times |
Groups & Lookarounds
| (abc) | Capturing group — captured as \1, \2… |
| (?:abc) | Non-capturing group |
| (?P<n>) | Named capturing group (Python syntax) |
| a|b | Alternation — matches a or b |
| (?=…) | Positive lookahead — followed by… |
| (?!…) | Negative lookahead — NOT followed by… |
| (?<=…) | Positive lookbehind — preceded by… |
| (?<!…) | Negative lookbehind — NOT preceded by… |
Replace Syntax (Python re)
| \1 \2 | Insert capture group 1, 2… |
| \g<1> | Insert group by number (unambiguous) |
| \g<name> | Insert named capture group |
0 matches
Results will appear here...
| Group Name | Last Value |
|---|
🔍
Enter a pattern and test string, then click Test Pattern or just start typing.