Regex Tester
Test regular expressions live with the g, i, m, s and u flags, see every match and capture group, and try replacements. Free, in the browser.
About Regex Tester
The Regex Tester lets you build and test regular expressions live. Matches light up as you type, and you see every capture group and can try replacements.
Flags
g finds every match, i ignores case, m makes ^ and $ work per line, s lets . match new lines, and u turns on full Unicode.
Build step by step
Start with a pattern that matches one example, then add classes, groups and quantifiers while watching the matches.
Test both ways
Paste lines that should match and lines that must not, so you catch patterns that match too much.
Too much matched?
.* is greedy and grabs as much as possible. Try .*? or a more specific class.
Escape special characters
. * + ? ( ) [ ] { } ^ $ | and \ need a backslash when you mean the character itself.
JavaScript flavour
Patterns run in your browser's JavaScript engine, so they behave exactly like JavaScript regex.
Private
Everything runs in your browser. Nothing you paste is uploaded.
Quick reference
\d is a digit, \w a word character, \s white space and . any character. * means zero or more, + one or more, ? optional, and ^ and $ mark the start and end.
How to use Regex Tester
- Enter your pattern.
- Turn on the flags you need.
- Paste your test string and watch the matches.
- Add a replacement to preview the result.
- Add a replacement string with $1 or $2 to preview a find-and-replace before using it elsewhere.
Related guide: Regular Expressions for Beginners: Patterns You Will Use Every Week
Help & FAQ
What do the flags mean?
g finds all matches, i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines and u enables full Unicode matching.
Will our pattern work in other languages?
JavaScript regex is close to many languages but not identical. Features such as lookbehind, named groups and flags can differ in Python, PHP or Java, so test there as well.
Why does our pattern match too much?
Quantifiers like .* are greedy. Use .*? to match as little as possible, or be more specific about what you want.
How do we match an email address?
A simple pattern is fine for checking input, but full email validation is complex. Keep the rule loose and confirm by sending a message.
What does a capture group do?
Parentheses group part of the pattern and remember what it matched, so you can reuse it in a replacement as $1, $2 and so on.
How do we match a literal dot?
Write a backslash before it: \. A bare dot matches any character.
How do we swap two parts of a line with a regex?
Capture each part in a group and reorder them in the replacement. For example, the pattern (\w+), (\w+) with the replacement $2 $1 turns 'Khan, Asha' into 'Asha Khan'.
What does the u flag do?
It turns on full Unicode mode, so characters outside the basic range, such as emoji, are treated as single characters and Unicode property escapes work.
Why does our pattern freeze the page?
Patterns with nested quantifiers can backtrack for a very long time on some input. Make the pattern more specific, or avoid repeating a group that already repeats.
Does the tester send our text anywhere?
The matching runs in your browser, so your text stays on your device.