Urban Software
Free Tool

Free Regex Tester, match, explain, replace

Build and debug a regular expression against your own text and watch every match highlight as you type. See the capture groups broken out, named and numbered, preview a find-and-replace, toggle the flags one at a time, and start from a library of common patterns. Nothing you enter leaves your browser, and a built-in cheatsheet is one click away.

A regular expression either matches what you meant or it silently matches something slightly different, and the second kind of bug is the expensive one. You write a pattern that looks right, it passes on the one string you tested, and it quietly fails on the edge cases you never pasted in. Most people debug regex by trial and error in the language they are coding in, recompiling and re-running to see what changed, which is slow and hides what is actually happening. What you need is to see the match land in real time: exactly which characters were captured, which group holds what, what the greedy quantifier swallowed, and how flipping the global or case-insensitive flag changes the result. That immediate feedback is the difference between guessing at a pattern and understanding it.

01

What a regular expression is

A regular expression, or regex, is a compact language for describing a pattern in text: not a fixed string to find, but a shape to match. It is how you say find every email address, or split on any run of whitespace, or check that an input looks like a date. The same syntax runs almost everywhere, in JavaScript, Python, PHP, Go, your editor's find-and-replace and most command-line tools, which is what makes it worth learning once. This tester uses the JavaScript engine, so what you see here is exactly what runs in a browser or in Node.

02

Groups, flags, and why they are the whole game

Two features do most of the real work. Capture groups, written with parentheses, pull the useful part out of a match: wrap the pattern for the user and the domain of an email and you get each piece separately, and a named group like the one for a year makes that readable. Flags change how the whole pattern behaves: g finds every match instead of just the first, i ignores case, m makes the anchors treat each line separately, and s lets a dot match newlines. This tool honours the g flag rather than quietly forcing it on, so you can watch one match become all of them and understand exactly what the flag does.

03

Test and replace, side by side

Matching is only half of most jobs; the other half is rewriting. Switch to the Replace view and the tool runs your pattern as a find-and-replace, with full support for referencing captured groups in the output, so you can reformat dates, mask emails or restructure a list without leaving the page. Because everything runs live in your browser, you get the answer instantly and privately, and because it uses the standard engine, the replacement string you build here is the same one you paste into your code.

How to use it

  1. 1

    Write the pattern

    Type your expression into the slashes at the top, or start from a preset like Email or IPv4 and adapt it. Invalid patterns show a clear error instead of failing silently.

  2. 2

    Set the flags

    Toggle g, i, m, s, u and y. Each has a tooltip explaining what it does, and the matches update the instant you change one, so the effect of a flag is visible immediately.

  3. 3

    Read the matches

    Your test string highlights every match in place, and the table below breaks out each match with its position and its capture groups, named or numbered.

  4. 4

    Preview a replacement

    Switch to Replace, type a replacement using $1 or $<name> to reference groups, and see the rewritten text live. Copying the regex or the result asks you to sign in with a free account.

Common mistakes

Forgetting the global flag

Without g, the engine returns only the first match, which is why a replace seems to change just one occurrence. Add the g flag to match and replace every occurrence, and watch the match count jump to confirm it.

Greedy quantifiers that match too much

By default * and + are greedy and grab as much as they can, so a pattern like a quoted string can swallow everything between the first and last quote. Add a ? to make a quantifier lazy, or use a negated character class, and check the highlight to see where it now stops.

Unescaped special characters

Characters like . ( ) [ ] { } + * ? and | have special meaning. To match a literal dot or bracket, put a backslash in front of it. A pattern that matches far more than expected is usually an unescaped special character.

Trusting one test string

A pattern that passes on your one example can fail on the edge cases. Paste in the messy, real input, including the values you expect it to reject, and confirm it matches all the ones it should and none of the ones it should not.

Questions

Is this regex tester free, and is my data private?
Yes, it is completely free with no limits, and it runs entirely in your browser. The pattern and the text you test are never sent to or stored on a server. Signing in is only required to copy the expression or the replacement result, so your work can follow you across our other tools.
Which regex flavour does this use?
It uses the JavaScript regular-expression engine, the same one that runs in browsers and in Node. Most syntax is shared across languages, but features like lookbehind and named groups follow the JavaScript rules, so what you see here matches what runs in JavaScript exactly.
How do capture groups and named groups work?
Wrapping part of a pattern in parentheses captures whatever it matched, and those pieces appear in the groups column numbered from one. Writing a name at the start of a group, in the angle-bracket form, gives it a label instead of a number, which you can also reference in a replacement.
Can I do a find and replace?
Yes. Switch to the Replace view and enter a replacement string. Use $1, $2 and so on to insert numbered groups, or the named form to insert a named group, and the rewritten text updates live as you type.
What do the g, i, m and s flags mean?
g is global, which finds every match rather than only the first; i ignores case; m is multiline, which makes the start and end anchors match at every line break; and s is dotAll, which lets a dot also match newline characters. You can combine them freely.
Why does my pattern match more than I expected?
The two usual causes are a greedy quantifier grabbing too much, which you fix by making it lazy with a trailing question mark, and an unescaped special character behaving as an operator, which you fix with a backslash. Watch the live highlight to see exactly which characters the pattern is claiming.

Need this done properly, at scale?

The tool handles the one-off. When it's a system you're building, that's the paid version of the job, and we do that too.

Custom Software Development