Skip to main content

Regex Tester

Test JavaScript regular expressions with live match results, capture groups, and flags.

Written by Golam Rabbani, Founder & Lead Engineer

//g

Enter the regex pattern without surrounding slashes. Flags are set below.

Flags

Paste or type the text you want to test the pattern against.

How to use this regex tester

  1. Enter your regular expression pattern in the Pattern field — omit the surrounding slashes.
  2. Check or uncheck the flag checkboxes (g, i, m, s, u, y) to control matching behaviour.
  3. Paste or type the text you want to match against in the Test string field.
  4. Press Run to execute the pattern and see each match, its index, and any capture groups.
  5. Press Copy results to copy the full match summary to your clipboard.

About this regex tester

The regex tester lets you run a JavaScript regular expression against any block of text and immediately see every match, the character index where it starts, and the value of each capture group — numbered or named. Rather than embedding a pattern in code and guessing why it misfires, you can iterate in real time and confirm the pattern works exactly as expected before using it.

Under the hood, the tool passes your pattern and the selected flags directly to the JavaScript `RegExp` engine — the same engine powering browsers, Node.js, and Deno. With the `g` (global) flag active it calls `String.prototype.matchAll` and iterates every non-overlapping match in the input. Without `g` it runs a single `RegExp.exec` and returns only the first match. The other flags refine engine behaviour: `i` removes case sensitivity, `m` re-anchors `^` and `$` to line boundaries, `s` (dotAll) lets `.` cross newlines, `u` enables full Unicode and surrogate-pair handling, and `y` (sticky) pins each successive match attempt to the exact position the previous one ended — which is why `y` and `g` cannot be active together. Results are capped at 200 displayed matches; the header count still reflects the true total.

As a worked example, enter the pattern `(\d{3})-(\d{4})` with the `g` flag checked and paste "Call 555-1234 or 555-5678" into the Test string field. Pressing Run returns two matches: "555-1234" at index 5 (Group 1: "555", Group 2: "1234") and "555-5678" at index 18 (Group 1: "555", Group 2: "5678"). Swap the numbered groups for named ones — `(?<area>\d{3})-(?<local>\d{4})` — and the tool surfaces the group names alongside their values.

The regex tester is built for developers, QA engineers, and data analysts who need to craft or debug patterns quickly without writing throwaway test scripts.

FAQ

What is the regex tester used for?
It lets you interactively test a JavaScript regular expression against any text and inspect every match, its position, and the values captured by numbered or named capture groups. It is useful for building patterns, debugging unexpected results, or verifying that a regex behaves correctly before embedding it in code.
What do the different flags do?
`g` finds all matches; without it only the first match is returned. `i` disables case sensitivity. `m` makes `^` and `$` match line starts and ends rather than the full string boundary. `s` allows `.` to match newlines. `u` enables Unicode mode. `y` (sticky) requires each successive match to begin exactly where the last one ended.
Why can't I enable both `g` and `y` at the same time?
The `g` (global) and `y` (sticky) flags define conflicting match-position semantics and cannot be combined in a single `RegExp`. When you toggle one on, the tool automatically turns the other off to prevent an invalid pattern.
How do I escape special characters in the Pattern field?
The pattern is interpreted as a raw regex, not a string literal, so you do not need to double-escape. To match a literal dot, enter `\.`; for a literal backslash, enter `\\`. Characters with special meaning in regex — `. * + ? ^ $ { } [ ] | ( )` — must each be preceded by a backslash to be treated as literals.
What is the difference between capture groups and lookarounds?
A capture group `(...)` participates in the match and its content appears as a numbered or named group in the results. A lookahead `(?=...)` or lookbehind `(?<=...)` asserts that text exists before or after the current position without consuming it — so its content does not appear as a captured group.
Can a complex pattern cause the tool to hang?
Yes. Patterns with nested quantifiers such as `(a+)+` on certain inputs can trigger catastrophic backtracking, causing the JavaScript engine to run for a very long time. If the page becomes unresponsive, reload the tab. Test patterns incrementally and avoid deeply nested quantifiers on large inputs.