Skip to main content

Regex Tester

Validate JavaScript regular expressions and inspect match positions, capture groups, and replacement results in real time.

Enter only the pattern without surrounding slashes. Backslashes are passed directly to JavaScript RegExp.

Flags

Supports multiple lines, Korean, Japanese, and Emoji. Indexes use JavaScript UTF-16 positions.

Match information

Match preview

Enter a pattern and test string to highlight matches.

Multiple test cases

Add several strings at once to compare matches and capture groups against the same pattern.

No test cases added yet.

Use JavaScript tokens such as $&, $1, $2, $<name>, and $$.

Replacement preview

—

Regex examples

These are simple format examples, not complete validators. Your test string is preserved.

JavaScript regex quick reference

Based on the current browser's JavaScript RegExp syntax.

Character classes

. any character \d digit · \w word character \s whitespace · [abc] set

Quantifiers

* zero or more · + one or more ? zero or one {n} exactly n · {n,m} range

Anchors

^ start · $ end \b word boundary · \B non-boundary

Groups

(...) capturing (?:...) non-capturing (?<name>...) named

Lookaround

(?=...) positive ahead (?!...) negative ahead (?<=...) positive behind

Escape

\. dot · \\ backslash \t tab · \n newline

Privacy: your pattern, test string, and replacement are processed only inside a browser Worker and are never uploaded or stored.

Share

What does the Regex Tester do?

It runs JavaScript regular expressions against test text, shows matches and capture groups, previews replacements, and supports checking multiple test rows. The existing syntax reference remains the detailed guide for supported constructs.

How to use it

  1. 1

    Enter a pattern and flags

    Use JavaScript regular-expression syntax without surrounding slash delimiters.

  2. 2

    Add test text

    Run the pattern against the main text and inspect highlighted matches and captures.

  3. 3

    Check replacement or batch cases

    Preview replacement output or add rows to compare which samples match.

Practical examples

Capture a date

Pattern: (?<year>\d{4})-(\d{2})-(\d{2})
Flags: g

Normalize whitespace

Pattern: \s+
Replacement: single space

Processing rules and limitations

  • JavaScript behavior

    Syntax and flags follow the JavaScript RegExp engine, not PCRE, Python, or .NET.

  • Execution safeguards

    Pattern, text, matches, detail, highlighting, and replacement output are capped to keep the page responsive.

  • Global flag

    Without g, JavaScript reports the first match; with g, matching continues until the configured safety limit.

Patterns and test data remain local

Regex execution runs inside a browser Worker. Patterns, test strings, and replacements are not uploaded or stored.

Frequently asked questions

Should I include /pattern/ delimiters?

No. Enter only the pattern and select flags separately.

Why does a PCRE expression fail?

JavaScript supports a different feature set and syntax from PCRE and other regex engines.

Can a regular expression freeze the page?

Some patterns are computationally expensive. The tool uses a Worker and limits, but patterns should still be tested with realistic input.

Related text and developer tools

Other popular tools