Test · Developer

Regex Tester

Write a pattern, set flags, and see matches and groups update live.

Matches

2

Flags

gi

Matches

  • [8] ada@example.com

    Groups: $1=ada · $2=example.com

  • [36] bob@toolsweb.dev

    Groups: $1=bob · $2=toolsweb.dev

What is Regex Tester?

The Regex Tester lets you build and run regular expressions against sample text and see every match and capture group update live. It uses JavaScript's built-in RegExp engine, which is defined by the ECMAScript Language Specification (ECMA-262), so results match exactly what your JavaScript or TypeScript code will do in the same environment.

A regular expression is a compact pattern language for describing sets of strings. You provide a pattern and a set of flags; the engine scans your text and reports each match along with the substrings captured by parenthesized groups.

The tool runs entirely in your browser. Your pattern and sample text stay on your device.

Why Use This Tool?

Writing a regex blind is slow and risky. Seeing matches highlighted as you type turns pattern design into a tight feedback loop, so you can refine anchors, quantifiers, and character classes with confidence before pasting the pattern into your codebase.

  • Validate patterns against real sample data.
  • Inspect the exact substrings captured by each group.
  • Experiment with flags without editing your code.
  • Confirm behavior in the same engine your app uses.

How Does This Tool Work?

The tool constructs a RegExp from your pattern and flags. To list every match in the UI, it always evaluates with the global flag internally, iterating with exec() and collecting each match, its index, and its capture groups. For zero-length matches it advances the position by one to avoid an infinite loop, and a large internal guard caps runaway iteration.

Supported flags are the standard ECMAScript set: g (global), i (ignore case), m (multiline anchors), s (dotAll), u (Unicode), and y (sticky). Invalid patterns produce the engine's own SyntaxError message.

Understanding Your Results

Each result row shows the matched text, the zero-based index where the match starts, and any capture groups in order. Group 1 corresponds to the first opening parenthesis, group 2 to the second, and so on; non-participating optional groups appear as undefined.

If you see fewer matches than expected, check whether you intended case-insensitive matching (i), whether ^ and $ should match line boundaries (m), or whether . should cross newlines (s).

Why Tracking This Matters

Regular expressions power validation, parsing, log analysis, and search-and-replace across nearly every language. A subtly wrong pattern can silently accept bad input or miss real matches, so testing against representative data before shipping prevents production bugs.

Benefits of Using Regex Tester

  • Live match list with indices
  • Per-group capture display
  • All standard ECMAScript flags
  • Uses the browser's native engine
  • Clear syntax-error reporting
  • Private, in-browser evaluation

How Is the Result Calculated?

There is no arithmetic here — matching is defined by the ECMAScript RegExp semantics. The engine attempts the pattern at each position, backtracking as needed, and reports the leftmost matches. Because JavaScript regex is not the same dialect as PCRE, POSIX, or RE2, features like lookbehind, named groups, and Unicode property escapes follow ECMAScript rules specifically.

Tips for Better Results

  • Add the u flag when working with emoji or non-BMP characters.
  • Use named groups like (?<year>\d{4}) for readable captures.
  • Prefer specific quantifiers over .* to avoid catastrophic backtracking.
  • Escape literal metacharacters such as . ( ) [ ] { } * + ? with a backslash.
  • Remember this is JavaScript regex, not PCRE — some syntax differs.

Standards and References

Conclusion

The Regex Tester gives you a live, accurate view of how a pattern behaves in the real JavaScript engine, including matches, indices, and capture groups.

Design and verify patterns here first, then paste them into your code knowing the semantics are identical in the same runtime.

Privacy & how it works

This developer utility runs in your browser with JavaScript and Web APIs. Your text, tokens, and secrets are not uploaded to The ToolSphere servers for this tool. Privacy Policy.

FAQ

Which regex engine does this use?expand_more

It uses your browser's built-in JavaScript RegExp engine, defined by ECMA-262. Results match what your JavaScript or TypeScript code produces in the same runtime.

Is this the same as PCRE or Python regex?expand_more

No. JavaScript regex is a distinct dialect. Some constructs from PCRE, .NET, or Python behave differently or are unavailable, so copy patterns between languages with care.

What do the flags mean?expand_more

g matches globally, i ignores case, m makes ^ and $ match line boundaries, s lets . match newlines, u enables full Unicode mode, and y makes matching sticky at lastIndex.

Why is the global flag always applied?expand_more

The UI lists every match, which requires iterating the whole input. The tool evaluates globally internally even if you omit g, so you always see the complete match list.

How are capture groups numbered?expand_more

Groups are numbered by the position of their opening parenthesis, left to right, starting at 1. Group 0 is the full match.

Does it support named capture groups?expand_more

Yes, using the (?<name>...) syntax supported by modern JavaScript engines. The captured text appears in the group list.

Why did my pattern match nothing?expand_more

Common causes are unescaped metacharacters, missing the i flag for case, or expecting . to match newlines without the s flag. Check those first.

Can a pattern hang the page?expand_more

The tool advances past zero-length matches and applies an internal iteration guard, but pathological patterns can still be slow. Avoid nested unbounded quantifiers like (a+)+.

How do I match a literal dot or slash?expand_more

Escape it with a backslash: \. matches a period and \/ matches a slash. Unescaped, a dot matches almost any character.

Is my text sent anywhere?expand_more

No. Pattern compilation and matching happen entirely in your browser. Nothing is uploaded to The ToolSphere servers for this tool.

Is this tool free?expand_more

Yes. No signup and no paywall for core use.

Is my text uploaded?expand_more

No for this tool. Text stays in your browser while you work.

Suggest an improvement

Tell us what would make this tool more useful. We read every suggestion.

Feedback for: Regex Tester