Regex Tester
Test JavaScript regular expressions with live highlighting, groups and a replace preview.
Syntax cheat sheet
- .
- Any character (except newline)
- \d \w \s
- Digit, word character, whitespace (capitalise to negate)
- [abc] [^abc] [a-z]
- Any of, none of, a range
- ^ $ \b
- Start, end, word boundary
- * + ? {2,4}
- Zero or more, one or more, optional, between 2 and 4
- *? +?
- Lazy versions: as few as possible
- (abc) (?:abc)
- Capture group, non-capturing group
- (?<name>abc) \k<name>
- Named group, and a back-reference to it
- a|b
- Either a or b
- (?=a) (?!a) (?<=a) (?<!a)
- Lookahead / lookbehind, positive and negative
- \p{L} \p{Lu}
- Unicode letters / uppercase letters (needs the u flag)
Uses your browser’s JavaScript regex engine (ECMAScript), so results match what your JS code will do. Other languages differ in small ways, especially lookbehind, named groups and flags. Patterns run in a background worker and are stopped after 1.5 seconds, which protects the page from catastrophic backtracking.
Runs entirely in your browser. Nothing you enter is sent to a server, saved, or logged.