Skip to content

Regex tester

Write the body only — no surrounding slashes.

Find every match instead of stopping at the first.

Treat upper and lower case as the same letter.

^ and $ match at the start and end of each line rather than of the whole text.

Lets . match a newline, which it otherwise never does.

Treats surrogate pairs (emoji, some CJK) as single characters and enables \u{1F600} escapes.

$1, $2 … refer to capture groups, $& to the whole match and $<name> to a named group. Write $$ for a literal $.

Common syntax
.
Any character except a newline (the s flag includes newlines)
\d / \D
A digit / anything but a digit
\w / \W
A letter, digit or underscore / anything else. CJK is not in \w
\s / \S
Whitespace (space, tab, newline) / anything else
[abc] / [^abc]
One of a, b, c / any character that is not one of them
[a-z] / [0-9]
A range inside a character class
a* / a+ / a?
a zero or more times / one or more / zero or one
a{2} / a{2,} / a{2,4}
Exactly twice / at least twice / between two and four times
*? / +?
Lazy. Quantifiers are greedy by default, which is why <.+> swallows a whole line
^ / $
Start / end. With the m flag, of each line
\b
A word boundary. \bcat\b does not match concatenate
(…) / (?:…)
Capture a group / group without capturing
(?<name>…)
A named group, referred to as $<name> in a replacement
a|b
Either a or b. Bracket it — ^(a|b)$ and ^a|b$ mean different things
(?=…) / (?!…)
A position followed by / not followed by that. The lookahead is not part of the match
\. \/ \( \[
Escape a symbol with a backslash to match it literally

Enter a pattern and some text; the matches and captured groups appear here.

Enter a pattern and flags (g / i / m / s / u) and the matches are highlighted in your text. Capture groups are listed by number and name, the replacement is previewed live, and an invalid pattern shows the engine’s error instead of breaking the page.

Questions

Which flavour of regex is this?

The JavaScript engine built into your browser. The basics carry over to Python, PHP and Ruby, but the details — lookbehind support, flag names, whether \A and \z exist — do not. Check the target language before moving a pattern across — the treatment of newlines, the syntax for named groups and what counts as a digit are the usual differences.

Should I include the slashes?

No. Write only the body; /abc/g would be read as a pattern that searches for literal slashes. Flags are the checkboxes under the field. When lifting a pattern out of an editor or a config file, strip the surrounding slashes and the trailing flag letters before pasting.

Nothing matches — where do I start?

Check the i flag (case) and the m flag (what ^ and $ mean), then whether symbols are escaped: . and ( mean something else unescaped. Shortening the pattern until it starts matching is the reliable way to find the piece that is wrong: start with the first few characters, confirm they match, then add one condition at a time.

Why does it stop after so many matches?

The list is capped at 500. A pattern that matches single characters produces enormous numbers of them, and putting all of those rows on the page makes it unusable. When the cap is reached the page says so. The replacement preview is unaffected and applies throughout. The table lists the first 50, while the highlighting covers every match up to the cap.

Is my text uploaded?

No. Matching and replacing happen entirely in the page, so log extracts and message bodies that you would not paste into a hosted regex site are fine here. The pattern is not sent anywhere either, which matters when it encodes the shape of an internal identifier.

Sponsored links