Skip to regex tester
Edwin Lab

JavaScript Regex Tester

Try a pattern, inspect its matches, and see exactly what each capture group contains. Everything runs in this browser.

Maximum 4 KiB UTF-8. Empty patterns are valid. Flags are selected separately.

Flags

Maximum 128 KiB UTF-8, 2,000 matches, and 2 MiB of result text/captures. Runs stop after two seconds. Use Ctrl/⌘ + Enter to run.

Ready. Enter a pattern and test text, or choose an example.

Test a regular expression

  1. Enter the pattern without surrounding slashes, such as \d+.
  2. Select flags and enter a small sample of test text.
  3. Run, inspect the highlighted ranges and capture table, then revise the pattern.

For \d+ with g and a12 b3, the matches are 12 at index 1 and 3 at index 5. Without g, only the first match is returned. The email example is a simple demonstration, not a comprehensive email validator.

What each flag means

  • g: find successive matches instead of only the first.
  • i: ignore letter case according to JavaScript rules.
  • m: let ^ and $ match line boundaries.
  • s: allow . to include line terminators.
  • u: interpret the pattern in Unicode mode, including code-point escapes and Unicode properties supported by this browser.
  • y: match only at the current position. The initial position is index 0; sticky matching will not skip forward to find a match.

No flag is added automatically. Combining g and y finds consecutive sticky matches only.

Capture groups and empty matches

Parentheses such as (a)(b)? create numbered captures. A group that did not participate is shown as Not matched, distinct from a group that matched an empty string. A named group such as (?<word>[A-Za-z]+) also appears under its original name. Copied results use matched: false and a null value for a non-participating group.

Patterns can match an empty range. The tester shows its position and advances one Unicode code point with u, or one UTF-16 code unit otherwise, to keep global iteration finite. Indices use JavaScript UTF-16 offsets: an emoji such as 😀 occupies two code units, not one byte or one grapheme index.

Frequently asked questions

Which regex engine does this use?

Your browser's JavaScript RegExp engine, isolated in a Web Worker. Engine features depend on the browser version. No external regex library is loaded.

Why does a PCRE or Python pattern fail?

Syntax and flags vary between engines. This tester supports JavaScript syntax and the six flags shown above; PCRE, Python, and Java patterns may require changes.

Why can a test time out?

Some patterns backtrack extensively on certain text. After two seconds the worker is terminated. You can also cancel, edit input, or run again with a smaller sample. A completed test does not prove a regex is safe from excessive backtracking in production.

Why are some results limited?

The tester stops at 2,000 matches or a 2 MiB result budget. A Results limited message means some text may not have been examined. No pattern or input is uploaded, saved to browser storage, or added to the URL.

Related developer tools

Inspect URL escapes with the URL Encoder / Decoder, validate a payload with JSONLint, or explore Developer Tools.