Skip to content
TinySolve

Regex Tester

Test a regular expression against real text, with capture groups, replacement and a safety net.

Runs in your browser — nothing you type is sent anywhere

//g
Try:

About the Regex Tester

Writing a regular expression is mostly a loop: try a pattern, look at what it matched, adjust. Doing that against real text rather than in your head is the entire point of a tester, and seeing the capture groups separately is usually what tells you which part is wrong.

Every match is listed with its position and the contents of each numbered and named group, including the groups that did not participate — which are shown as such rather than silently omitted. That distinction matters when you are debugging an alternation, because a group being empty and a group not matching at all mean different things.

The replacement box uses the same references as JavaScript's own replace: dollar-one for a numbered group, dollar-angle-brackets for a named one, and dollar-ampersand for the whole match. What you see here is therefore exactly what your code will produce, rather than an approximation.

The unusual part is the safety net. A pattern with one repetition nested inside another, such as an inner plus wrapped in an outer plus, can take exponential time on certain inputs — the tab freezes, with no error and no way to stop it. This tester runs the match in a background thread and stops it after two seconds, then explains what happened. Patterns with that shape are flagged before you even run them.

Everything happens on your device, so the text you are testing against never leaves it.

How to use the Regex Tester

  1. Write your pattern

    Type it between the slashes, or start from one of the examples for email addresses, URLs, dates and more.

  2. Set the flags

    Global finds every match, ignore-case is self-explanatory, and multiline changes what the anchors mean. Each button explains itself on hover.

  3. Paste your test text

    Matches appear immediately, each with its position and the contents of every capture group.

  4. Try a replacement

    Turn on the replacement box to see the rewritten text, using the same group references your code would use.

Frequently asked questions

Why did my regex freeze other testers but not this one?
Because a pattern with nested repetition can backtrack exponentially, and most testers run it on the main thread where it cannot be interrupted. This one runs matching in a background worker and terminates it after two seconds, so the page stays usable and you get told what happened.
What is catastrophic backtracking?
When a pattern can match the same text in many different ways, the engine tries all of them before giving up. Nesting one unbounded repetition inside another, such as an inner plus inside an outer plus, multiplies the possibilities and the time taken grows exponentially with input length.
Which flavour of regular expression is this?
JavaScript's, because it runs in your browser. It is close to PCRE for everyday patterns, but lookbehind, named groups and unicode property escapes all follow JavaScript's rules, so a pattern tested here will behave identically in JavaScript and may differ slightly in Python or PHP.
Why is one of my capture groups showing as no match?
Because that group is inside an alternation that was not taken. A group which does not participate in the match is undefined rather than empty, and the difference matters — your code will get undefined, not an empty string.
Does the replacement work the same as in my code?
Yes. It uses the browser's own String.replace, so dollar-one, dollar-angle-name and dollar-ampersand behave exactly as they will in JavaScript. There is no separate implementation to disagree with.
Is my test text sent anywhere?
No. The pattern and the text stay in your browser, including inside the background worker. Nothing is transmitted at any point.