Skip to main content
eyunzhu

Regular expression tester

Test JavaScript regular expressions, inspect match positions and capture groups, and preview text replacements as you type.

Updates as you type or change an option

Matches

Replacement preview


Processed in this browser. Nothing is uploaded or saved.

About this tool

Debug patterns for browser and frontend code with the pattern and flags in separate fields. Long-running expressions stop rather than blocking the page indefinitely.

How to use

Enter a pattern without enclosing slashes, its flags and some test text. Use g for all matches, i to ignore case and m for multiline anchors. Replacements support JavaScript syntax such as $1 and $.

Expressions run in a separate worker and stop after 1.5 seconds. Limits are 100,000 text characters, 4,000 pattern characters and fewer than 2,000 matches. Narrow the input if results become too large.

Common questions

Why does a PHP or Java regex fail here?

This uses the JavaScript regex engine, whose syntax and flags differ from other engines. Omit enclosing slashes. Replacement strings support JavaScript forms such as $1 and $<name>.

Why does the tester find only the first match?

Add g to the flags to find all matches. i ignores case; m changes how ^ and $ treat lines, but does not make a dot match line breaks.

How can I swap two captured words?

With pattern (\w+) (\w+) and replacement $2 $1, Ada Lovelace becomes Lovelace Ada. $& inserts the whole match and $$ inserts a literal dollar sign. Copy the replacement preview when it is correct.

What should I do after a timeout or match-limit error?

Reduce the test text or make the pattern more specific. Tasks stop after 1.5 seconds; reaching 2,000 matches is also rejected. Partial matches are not presented as a complete result.

Comments

0
to join the discussion.
No comments yet.
Reply thread

Follow the complete conversation chronologically; each reply identifies the specific message it answers.