Skip to main content
Back to tools

Regex Tester

Test regular expressions and highlight matches in real time

About Regex Tester

Enter a pattern and some sample text to see every match highlighted as you type, with each match's position and capture groups listed below. Switching between JavaScript, PHP and Java changes the flag buttons and generates a copy-ready code snippet for that language, and a collapsible cheat sheet covers character classes, quantifiers, anchors and groups. It only finds matches; there is no replace mode.

Category: Text.

Frequently asked questions

What regex flavor does this use?

▾

Matching always runs on your browser's JavaScript RegExp engine, even in PHP or Java mode, which only change the available flags and the generated code snippet. Syntax JavaScript doesn't support, such as possessive quantifiers (a++), atomic groups (?>...) or inline flags like (?i), is reported as an error.

What are the available flags?

▾

JavaScript mode offers g, i, m, s and u, with g (find all matches) on by default. PHP mode adds x, and Java mode offers i, m, s, x and u but no g, so only the first match is listed; x is written into the snippet but not applied to the live matching.

What's the difference between a match and a capture group?

▾

A match is the full text the pattern found, while a capture group (parentheses) extracts part of it. The tester lists each match with its start index and its group values in order, showing undefined for groups that didn't participate; named groups (?<name>...) appear by position, not by name.

How do I match a literal dot, slash, or bracket?

▾

Prefix special characters with a backslash to match them literally. For example, a backslash before a dot matches a literal dot; without it, a dot matches any character.

Related tools