Regex Tester

Developer Tools

Test and debug regular expressions in real-time.

⚡ Instant🔒 Private, in your browser🆓 Free, no sign-up👥 For developers
Your data never leaves your browser. We do not store inputs.

What Regex Tester does

The Regex Tester checks that a regular expression is valid and shows every match in your sample text, highlighted, with its position and capture groups. It uses your browser's JavaScript regex engine and reports syntax errors immediately.

FV
Reviewed by the FreeToolsVerse team · Last updated · How we check our tools

Features and benefits

  • Highlights every match in your sample text and lists each match with its position
  • Shows capture groups for each match
  • Accepts a pattern with separate flags or a full literal such as /abc/gi
  • Reports syntax errors immediately, and the text stays in your browser

How to use Regex Tester

  1. Enter your pattern, or paste a full /pattern/flags literal
  2. Set the flags (g finds all matches, i ignores case, m and s change anchors and dots)
  3. Paste the text to test against
  4. Review the highlighted matches, positions and captured groups

Who should use it

Made for developers. Typical uses:

  • Testing regex patterns before using in code
  • Debugging complex regular expressions
  • Learning regex by experimenting with patterns

Example

The pattern \b[\w.+-]+@[\w-]+\.[\w.]+\b on "Contact ada@example.com or grace@navy.mil today." highlights two matches, ada@example.com at position 8 and grace@navy.mil at position 27. The pattern (\d{4})-(\d{2})-(\d{2}) on "2026-10-05 and 1999-12-31" finds two dates with the year, month and day as groups.

Limitations and accuracy

It runs the JavaScript regex flavor. Other languages (PCRE, Python, Java) differ on features such as lookbehind and possessive quantifiers.

Accuracy: Output is tested against known inputs. For production code, review the result and run your own tests.

Expert Tip

Build a pattern in small steps: start with the simplest version that matches, add one rule at a time, and keep a few sample lines that should not match as well as those that should.

Frequently asked questions

Which regex flavor does it use?
JavaScript (ECMAScript), the same engine your browser uses. Patterns that work here work in JavaScript and Node.js; other languages may differ slightly.
What do the flags do?
g finds all matches, i ignores case, m makes ^ and $ match at each line, s lets . match newlines, u enables Unicode and y matches only at the current position.
Is my text uploaded?
No. Matching runs entirely in your browser.

Regex Tester: the complete guide

What the tester shows

A regular expression is a pattern for finding text. The Regex Tester checks that your pattern is valid, then highlights every match in your sample text and lists each match with its position and its capture groups. Syntax errors are reported straight away. You can type a pattern and set the flags yourself, or paste a full literal such as /abc/gi and the tool reads the pattern and flags from it.

Flags

Flags change how matching works. The tool accepts the JavaScript flags d, g, i, m, s, u, v and y, and starts with g.

  • g finds all matches instead of stopping at the first.
  • i ignores upper and lower case.
  • m lets the anchors ^ and $ match at the start and end of each line.
  • s lets the dot match line breaks.
  • u turns on full Unicode matching.

Two worked examples

To find email-like text, the pattern \b[\w.+-]+@[\w-]+\.[\w.]+\b applied to "Contact ada@example.com or grace@navy.mil today." matches ada@example.com at position 8 and grace@navy.mil at position 27.

Capture groups pull out parts of a match. The pattern (\d{4})-(\d{2})-(\d{2}) applied to "2026-10-05 and 1999-12-31" matches both dates, and the groups give the year, month and day of each: 2026, 10, 05 and 1999, 12, 31.

Building patterns

A short vocabulary covers most patterns.

  • \d is a digit, \w a letter, digit or underscore, \s a space-like character, and a dot is any character except a line break.
  • ^ and $ anchor to the start and end, and \b is a word boundary.
  • * means zero or more, + one or more, ? zero or one, and {2,4} two to four.
  • Parentheses make a group, a vertical bar means or, and square brackets list a set of characters.
  • A backslash makes a special character literal, so a real dot is \.

Pitfalls

The flavour matters: this tester uses the JavaScript engine, so features such as possessive quantifiers differ from PCRE, Python or Java. Quantifiers are greedy by default, so .* grabs as much as it can; add a question mark (.*?) to take as little as possible. Forgetting to escape a dot makes a pattern match too much. Nested repetition such as (a+)+ can take extremely long on certain inputs, so keep patterns simple. If you need the pattern as a string for code, the Regex to String tool escapes it correctly.

For a deeper check on email addresses, see why a pattern is not enough in what validators catch and what they miss. The Email Validator applies stricter rules. Everything runs in your browser.

Testing habits that save time

Write test lines that should match and lines that should not, including edge cases such as empty input, extra spaces and unusual characters. A pattern that finds what you want in one sample may also find things you do not want in another. Check the position of each match, because an off-by-one error is easy to miss, and re-run the test with the g and i flags switched on and off to see how the result changes.

Learning resources

Explore more in Developer Tools, read the guides and articles, or see how we test our tools.

Share This Tool