Skip to content

Regex Tester

Test a regular expression against your text, safely.

A JavaScript regular expression.

Any of g i m s u y. Use g to find every match.

Matching runs entirely in your browser. Nothing is uploaded.

Results

Enter a pattern and some test text to see matches.

How the regex tester works

The tester takes three inputs: your pattern, the flags string (such as g, i, m, u), and the test text. It compiles them with the browser’s native engine using new RegExp(pattern, flags), so the results are exactly what JavaScript would produce. There is no separate regex implementation to drift out of sync.

Matching depends on whether a global flag is present. Without g (or the sticky y flag), the engine runs once and returns the first match, if any. With g or y, the tester loops, calling the engine repeatedly and collecting every match until the text is exhausted. A zero-width match (a pattern that matches no characters, like a* against b) would otherwise leave the cursor in place, so after each empty match the cursor advances by one position. That guarantees the loop always ends. For every match it records the matched text, the start index, and the capture groups, keyed 1, 2, and so on for positional groups plus any named groups.

Worked example

Pattern (\d{4})-(\d{2}) with the g flag, run against:

Logs: 2026-06 and 2025-12 then 2024-01.

The engine scans left to right and finds three matches. Each one captures a four-digit year in group 1 and a two-digit month in group 2:

Match Text Index Group 1 Group 2
1 2026-06 6 2026 06
2 2025-12 18 2025 12
3 2024-01 31 2024 01

The total count is 3. The index values are the character positions where each match begins, counting from zero. 2026-06 starts at position 6 because Logs: (including the trailing space) occupies positions 0 through 5.

How to use it

  • Type the pattern without the surrounding slashes. Put flags in the separate flags box.
  • Add g to find every match. Leave it off to inspect only the first one.
  • Use i for case-insensitive matching, m to make ^ and $ match line boundaries, and u for full Unicode support.
  • Wrap parts of the pattern in parentheses to capture them, or use (?<name>...) to label a group and read it back by name.
  • If you see an error message, check for an unbalanced parenthesis or bracket, an unescaped special character, or a stray flag letter.

Limitations

This tool uses the JavaScript regex engine, so patterns written for PCRE, Python, Java, or .NET may behave differently or fail to compile. Input is capped at 100,000 characters and results at 10,000 matches, so very large texts must be trimmed first. It tests matching only; it does not perform replacements, explain why a pattern failed, or rate performance, though the input and match caps protect the page from a slow pattern. Results reflect your browser’s engine version, which can vary slightly between browsers for newer features.

Frequently asked questions

Which regex flavor does this use?

It compiles your pattern with the browser's own JavaScript engine using `new RegExp(pattern, flags)`. That means the behavior matches what you would get in JavaScript code, including features like named groups, lookbehind, and Unicode property escapes where the browser supports them. It is not PCRE, Python, or .NET, so a few constructs from those flavors will not apply.

Why do I see an empty match in my results?

Patterns like `a*`, `\b`, or `(?=x)` can match zero characters. With the global flag, the tester records the empty match, then advances the cursor by one position so the search keeps moving instead of looping forever on the same spot. The empty match shows a blank matched string but still carries a start index.

What do the numbered and named entries under each match mean?

Each match lists its capture groups. Positional groups are keyed `1`, `2`, and so on, in the order their opening parentheses appear. Named groups, written `(?<year>\d{4})`, also appear under their name. A group that did not participate in the match shows as undefined.

Is there a limit on how much text or how many matches it handles?

Yes. Input is capped at 100,000 characters and the tester collects at most 10,000 matches for a global search. These bounds keep a heavy pattern from freezing the page. If your text is longer, trim it or split it before testing.

My pattern shows an error instead of crashing. Why?

An invalid pattern such as an unclosed group `(`, or an unknown flag, is caught and reported as a readable message instead of throwing. Fix the pattern and the matches reappear. This lets you iterate without the tool breaking.