Regex tester
Write a regular expression, paste some text, and see every match, every group and the replaced result as you type.
Sealed on this device
Runs in your browser. Nothing is uploaded.
Sealed
Cheat sheet
Select a token to insert it into your expression.
- a digit 0–9
- a letter, digit or underscore
- a space, tab or line break
- any character except a line break
- one of the characters listed
- any character except those listed
- start of the text (or line)
- end of the text (or line)
- edge of a word
- zero or more of the previous item
- one or more of the previous item
- the previous item is optional
- between 2 and 4 of the previous item
- a capture group
- a named capture group
- either the left or the right side
- followed by…, without including it
- a literal dot (escape any special character with \)
Matches in the text
The expression took longer than one second and was stopped. Patterns with nested repetition, like (a+)+, can take exponentially long on some texts. Try making the repeated parts more specific.
Matches
- Matches
- 0
- Groups
- 0
Matches and their groups will be listed here.
Replace
Use $1, $2… for numbered groups, $<name> for named groups and $& for the whole match.
How it works
-
Write your expression
Type a pattern and choose its flags. The cheat sheet inserts common tokens if you don’t remember the syntax.
-
Paste some text
Matches are highlighted as you type, and each one is listed with its position and capture groups.
-
Try a replacement
Enter a replacement using $1 or $<name> to preview the result of a search and replace, then copy it.
Frequently asked questions
Which regex flavor does this use?
JavaScript’s, exactly as your browser runs it, including named groups, lookbehind and Unicode property escapes like \p{L}. Most of the syntax is shared with Python, PHP and Java, but some features differ.
Is my text sent anywhere?
No. The expression runs in your browser, in a separate background worker. Your pattern and your text never leave your device.
Why was my expression stopped?
Some patterns, often with a repetition inside another repetition, can try billions of combinations before failing. This is called catastrophic backtracking. The tester stops any run that lasts more than a second so the page never freezes.
What does the g flag change?
Without g, only the first match is found and only the first match is replaced. With g, every match in the text is found and replaced.
How do I match a dot, a bracket or a question mark literally?
Put a backslash in front of it: \. matches a dot, \( a parenthesis and \? a question mark. Inside square brackets, most characters are already literal.