Code drawer

Regex tester

Iterate on a pattern and see each match immediately.

Privacy built inYour work stays with you

Your work stays private in your browser while you use this tool.

In short

What does regex tester do?

Run a JavaScript regular expression over sample text, highlight non-empty matches, and list each match's index, numbered captures, and named groups. The scan collects up to 500 matches.

Input
A JavaScript regex pattern, flags, and test text.
Result
Match positions, captured text, and groups.
Price
Free
Account
Not required
A quick, useful guide

How to use regex tester

01

Add your input

A JavaScript regex pattern, flags, and test text.

02

Choose your settings

Iterate on a pattern and see each match immediately.

03

Save or copy

Match positions, captured text, and groups.

A practical tip

Avoid catastrophic backtracking patterns before using a regex on untrusted or very long input.

Practical uses

When to use regex tester

Test a validation or extraction pattern against representative strings before adding it to JavaScript.

Inspect capture groups and match positions while debugging a replacement workflow.

Compare the effect of flags such as i, m, s, u, or v on the same text.

Worked example

A concrete regex tester example

Input
Pattern red; flags i; text 'red green RED'
Result
Two matches are reported: red at index 0 and RED at index 10. The tester adds global scanning internally even though g was not entered.
What to expect

How it works

The page validates flags against d, g, i, m, s, u, v, and y and rejects duplicates. It constructs a native RegExp, adds g for scanning when absent, and iterates String.matchAll(). Empty matches appear in the result list but are omitted from visual highlighting to avoid overlapping zero-width marks.

Know before using

Limits and edge cases

  • Evaluation runs synchronously in the browser with no timeout. A pattern with severe backtracking can freeze the tab on adversarial or very long text.
  • Results stop at 500 matches, replacement output is not generated, and support for newer flags or syntax depends on the current browser's JavaScript engine.
References

Standards and sources

Common questions

Regex tester FAQ

Is regex tester free to use?

Yes. Regex tester is free to use.

Does regex tester keep my work private?

Yes. Your work stays private while you use the tool — nothing you enter is uploaded.

Why are all matches listed when I did not enter the g flag?

The tester adds g to its internal scanning expression so it can show every occurrence. Your other flags are retained.

Why is a zero-length match listed but not highlighted?

A zero-length match has an index but no visible characters to wrap. The result record remains useful, while the highlighter filters it out to avoid ambiguous marks.