Regex Tester
Test JavaScript regular expressions live — highlighted matches, capture groups, replace preview and a quick cheat sheet.
//g
Test text
Matches
Contact: somchai@example.co.th, support@utilitech.io Orders: #A-1024 on 2026-10-31, #B-77 on 2026-11-02 Phone: 081-234-5678 or +66 2 123 4567
Type a pattern
Replace
Turn on to preview a find-and-replace with this pattern.
Cheat sheet
- .
- any character except newline
- \d \w \s
- digit, word character, whitespace
- \D \W \S
- not digit / word / whitespace
- [abc] [^abc]
- one of / none of
- a* a+ a?
- 0 or more, 1 or more, 0 or 1
- a{3} a{2,5}
- exactly 3, between 2 and 5
- a*? a+?
- lazy (as few as possible)
- ^ $
- start / end of input (or line with m)
- \b
- word boundary
- (abc)
- capture group
- (?<name>abc)
- named group
- (?:abc)
- group without capturing
- a|b
- a or b
- (?=a) (?!a)
- followed by / not followed by
- (?<=a) (?<!a)
- preceded by / not preceded by
- $1 $<name> $&
- in replace: group, named group, whole match
How to use
- Type a pattern between the slashes and paste some text — matches are highlighted as you type.
- Click a flag to turn it on or off. Without
gonly the first match is found. - Match details lists every match with its position and capture groups, including named groups like
(?<year>\d{4}). - Turn on Replace to preview a find-and-replace. Use
$1,$<name>or$&for the whole match.
Good to know
- Patterns use the JavaScript regex engine of your browser. Most syntax is shared with PCRE, Python and Java, but some features (such as possessive quantifiers) are not.
- A pattern that takes too long (for example catastrophic backtracking) is stopped automatically.
- Everything runs in your browser — your text is never uploaded.