Regex tester

Try a regular expression on your text, see every match and group highlighted, and stop slow patterns safely.

Everything happens on your device. What you type never leaves it.

A JavaScript regular expression, without the slashes.

FlagsGlobal (g)Ignore case (i)Multiline (m)Dot matches line breaks (s)Unicode (u)Sticky (y)

The test text appears here with the matches highlighted.

Note:This tool uses the regular-expression flavour of your browser: JavaScript. Other languages can differ.

This tool needs JavaScript to run

About this tool

A regular expression, or regex, is a short pattern that describes text you want to find: every number, every email address, every line that starts with a word. Type a pattern, paste some text, and every match is highlighted in the text as you type. Below it, each match is listed with the groups it captured, by number and by name.

This tool uses the regular-expression flavour of your browser, which is JavaScript. Other languages such as Python, PHP or Java have small differences, so a pattern that works here may need a change there. The flags next to the pattern change how it matches: for example, "g" finds every match instead of only the first, and "i" ignores the difference between upper and lower case.

A badly written pattern can take a very long time on some text, and would freeze an ordinary page. Here the matching runs in a separate worker that is stopped after one second, so the page always stays usable and you are told that the pattern was too slow. Everything happens on your device; your text is never sent anywhere. The output is the matched text, one match per line, ready to copy or open with another tool.

Examples

Find every number

Input

Pattern: \d+   Flags: g   Text: Room 12, floor 3, door 405

Output

12
3
405

Capture the parts of an email address

Input

Pattern: (?<user>[\w.]+)@(?<host>[\w.]+)   Text: write to [email protected]

Output

Match 1: [email protected], group user: ana, group host: example.org

A pattern that is too slow

Input

Pattern: (a+)+$   Text: aaaaaaaaaaaaaaaaaaaaaaaaaaaa!

Output

This pattern took too long and was stopped.

Common questions

Which regular-expression flavour does this use?

The one built into your browser: JavaScript. Features such as named groups, lookbehind and Unicode property escapes work where your browser supports them. Patterns for other languages can behave differently.

What does "This pattern took too long and was stopped" mean?

Some patterns, such as nested repeats like (a+)+$, make the matcher try an enormous number of ways to fit the text when it does not match. The tool stops after one second so the page stays usable. Make the pattern more specific, or avoid repeating a group that contains a repeat.

Why is only the first match shown?

Without the global flag (g), a pattern stops at its first match. Turn on "Global" to find every match.

Is my text sent anywhere?

No. The pattern and the text stay in your browser, and the matching runs in a worker on your own device.

Why are some groups empty?

A group inside an optional part of the pattern, such as (x)?, does not take part in a match that skips that part. It is listed as "did not match".