Regex tester

Explains the pattern and its errors in plain English, stops a runaway pattern with a time limit instead of freezing, warns where Python, Java, PCRE or Go would behave differently, and writes the code for six languages.

In short

A regex tester runs a regular expression on sample text so you can see what it matches. This one highlights every match, lists the capture groups and positions, previews a replacement, and explains the pattern and any error in plain English. It uses the JavaScript engine and runs in your browser.

  • Plain-English explain
  • Six languages of code
  • Stops runaway patterns
  • Copy summary
  • Runs in your browser

Private by design. Nothing you type is uploaded or saved. Add this tool to your phone or computer for one-tap access.

Flags:

g Find every match, not only the first.

Matches highlighted

No matches. Check the flags (case, line starts) and the text.

Page last updated

How to use it

  1. Type your pattern between the slashes and choose the flags: g for every match, i to ignore case, m for line starts, s so the dot matches line breaks, u for Unicode.
  2. Paste the text to test. Matches are highlighted as you type, and listed with their position and groups.
  3. Open Explain to read the pattern part by part, or Replace to try a substitution such as $1 or $<name>.
  4. Add examples that should match and should not match in Tests to check the pattern as you change it.
  5. Open Code to copy the pattern for your language, and read the notes on what differs there.

How it calculates

The pattern runs on your browser’s own JavaScript regular expression engine, so results are exactly what JavaScript, TypeScript and Node.js give. The run happens in a background worker with a time limit, so a pattern that backtracks without end is stopped and cannot freeze the page. Matches are listed with their position and capture groups, using the d flag for exact group positions. The explanation is read from the pattern text itself. The notes on Python, Java, C#, PHP and Go come from those languages’ documentation and are never run.

For example, the pattern (\d{3})-(\d{3})-(\d{4}) with the g flag finds 2 matches in “Call 415-555-0132 or 415-555-0188 today.”: 415-555-0132 at position 5 and 415-555-0188 at position 21. Each match has three groups, the first being 415. Replacing with ($1) $2-$3 gives “Call (415) 555-0132 or (415) 555-0188 today.”. The explanation reads the pattern as 14 parts, starting with “start of capture group 1”. The text is made up; yours comes from what you type.

Who should use it

  • Developers writing or debugging a regular expression for JavaScript, TypeScript or Node.js
  • Anyone using Python, Java, C#, PHP or Go who wants a quick way to try a pattern and see where those languages differ
  • Learners who want each part of a pattern explained
  • People cleaning text with find and replace in an editor that supports regex

Who should not use this

  • Anyone who needs the exact behaviour of another engine: this runs JavaScript, and the notes on Python, Java, PCRE and Go are guidance, not a test run
  • Anyone validating security-critical input such as email addresses, passwords or HTML; a pattern is not enough for these, and the examples say so
  • Anyone testing text that is secret and must not be pasted into a web page; nothing is uploaded, but treat sensitive data with care on any shared computer

Limitations

  • Only the JavaScript engine is run. Python’s re, Java, .NET, PCRE (PHP) and Go (RE2) have differences in syntax and behaviour that the notes point out but do not test.
  • Text is limited to 200,000 characters and the match list to 2,000 matches, to keep the page responsive.
  • A pattern that takes more than about two seconds is stopped and reported. A pattern that is slow on some other text may still take long in your own program.
  • The plain-English explanation covers standard syntax. Unusual constructs are shown as they are, with a note that they are not explained.
  • The built-in examples find text of a certain shape. For example, the email pattern cannot tell if an address exists, and the date pattern allows 31 February.
  • Nothing is uploaded or stored on a server. Clearing your browser data also removes the saved profile.

Sources and review

Reviewed on 20 Oct 2026 against the published sources below. Rules and prices change, so check the current position before you rely on a figure.

Common questions

What is a regex tester?
A regex tester lets you try a regular expression on sample text before you use it in code. It shows what matches, what each group captured, and what a replacement would produce, so mistakes show up at once instead of when the program runs.
Which regex engine does this use?
Your browser’s JavaScript engine, the same one used by Node.js, TypeScript and Deno. What you see is what JavaScript will do. Other languages have a similar syntax with differences, which the Compatibility notes list for Python, Java, C#, PHP and Go.
How do I test a regex with capture groups?
Put part of the pattern in brackets, as in (\d+)-(\d+). Each match lists its groups with their text and position. Name a group with (?<year>\d{4}) and the name appears in the list. In a replacement, use $1 or $<year>.
Why do I get “nothing to repeat” or “unterminated group”?
Those are the browser’s own error messages. “Nothing to repeat” means a *, + or ? has nothing in front of it, usually a pattern that starts with one. “Unterminated group” means a bracket was opened and never closed. The tester turns each error into a plain sentence and a fix.
What is catastrophic backtracking?
Some patterns, such as (a+)+$, can take longer and longer on text that nearly matches, until the program seems to hang. This tester runs the pattern in a background worker with a time limit, so it stops and tells you instead of freezing, and it warns when a pattern has the risky shape.
What do the flags g, i, m, s, u and y do?
g finds every match rather than the first. i ignores case. m makes ^ and $ match at each line. s lets the dot match a line break. u reads the pattern as Unicode so emoji are one character and \p{L} works. y matches only at the position where the last match ended. Click a flag to see its meaning.
How do I write a regex for an email address, phone number or ZIP code?
The Examples list has patterns for each, with sample text. Treat them as finders, not validators: the email one cannot tell whether a mailbox exists, and the phone one does not check area codes. For checking input, validate on the server and send a confirmation.
Will my pattern work in Python, Java or PHP?
Often, but not always. Named groups are written (?P<name>...) in Python, a lookbehind must have a fixed length in Python and PCRE, and Go has no lookaround or back-references at all. The Code tab converts what it can and lists what to check.
Is my text sent anywhere?
No. The pattern and text are processed in your browser and are not uploaded. Some other online testers do send input to a server, so check before pasting private text elsewhere.

Guides that explain the rules

Related tools

This tool produces a document from the information you type. It does not give legal, tax or accounting advice, and it does not check that your figures or rates are right. See the disclaimer. Found a mistake? Report an error in a calculation.