Developer Utility

JavaScript Regex Tester

Enter a regular expression and test text to check matches, capture groups, and flag behavior in real time. Useful for validating emails, URLs, phone numbers, dates, hashtags, and code patterns.

Real-time matching Highlights matching results immediately when you enter a regex pattern and test text.
Flag testing Test regex behavior with g, i, m, s, u, and y flags.
Capture groups View match lists and capture groups as JSON and copy the results.

Regex test

Enter a regex pattern and test text to view match previews and result lists.

Expression /.../g
Matches 0 items Groups 0 items Text 0 chars Waiting to test

Match result

Matched strings are highlighted in the preview, and detailed results are shown as JSON.

Waiting to test

Match preview

0items
Enter test text to display matching results here.

Match list

[]

Capture groups

[]

Common regex examples

Click a common pattern to load the regex and sample text immediately.

Practical guide

Test JavaScript regular expressions with matching and nonmatching samples

Inspect matches, indexes and capture groups using the browser's JavaScript RegExp engine. Bounded worker execution helps keep accidental expensive patterns from blocking the page.

Who this helps

  • Developers testing text patterns
  • Users extracting structured fragments

When to use this tool

  • Capture parts of a date string.
  • Check Unicode and zero-length matches.

From input to a checked result

  1. 1

    Prepare masked text with positive and negative examples.

  2. 2

    Enter the pattern body without surrounding slashes.

  3. 3

    Choose the JavaScript flags required by the pattern.

  4. 4

    Run the test and inspect indexes and capture groups.

  5. 5

    Simplify expensive patterns and retest in the actual target runtime.

Example 1

Capture a date

Input
Pattern (\d{4})-(\d{2})-(\d{2}); text 2026-10-01
Result
Match 2026-10-01; groups 2026, 10 and 01.

Matching this shape does not validate a real calendar date.

Example 2

Unicode empty matches

Input
Pattern (?:); flags gu; text 😀
Result
Zero-length matches at UTF-16 indexes 0 and 2.

Unicode mode advances over the complete surrogate pair.

How it works

Limits are 500 pattern code units, 20,000 text code units, at most 1,000 matches and a 400ms worker timeout. Flags g, i, m, s, u and y follow JavaScript behavior. Empty matches advance by a code point in Unicode mode.

Limitations

  • JavaScript syntax differs from PCRE, RE2 and other engines.
  • A passing sample or worker timeout is not a production performance guarantee.
  • Worker startup can fail under restrictive browser policies.
  • The interface expects a test string; downloaded JSON contains matched input.
Your data

Patterns and text stay in the browser. Remove private log values before testing or exporting results.

Frequently asked questions

Why does an index count an emoji as two?

Match indexes and lengths use UTF-16 positions, even when u matches whole code points.

Can I return exactly 1,000 matches?

Yes. A 1,001st match stops the test rather than returning a silently truncated report.

Why did the worker time out?

The pattern exceeded the local execution budget. Review nested repetition and overlapping alternatives.