Regex Tester

Test a JavaScript regular expression against your text and see every match and capture group, in your browser.

Runs entirely in your browser. Nothing is uploaded, logged or stored.

Without the surrounding slashes.
Any of g i m s u y d v.

Highlighted


    

Write a pattern, paste the text you expect it to match, and see immediately what it catches and what it misses, with every capture group broken out.

How it works

The pattern is compiled by your browser and run against the subject as you type. What you see is exactly what the same expression will do in JavaScript, because it is the same engine.

With the g flag every match is listed; without it only the first is. The i flag ignores case, m makes ^ and $ match at line boundaries, s lets the dot match a newline, u turns on Unicode mode and y anchors the search at the last index.

Numbered capture groups appear in order; a group written as (?<name>...) is shown under its name.

Examples

Case Input Result
An ISO date, split into its parts (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) year, month and day as named groups
Every hashtag in a post #\w+ one match per hashtag, with the g flag

Frequently asked questions

Which flavour of regular expression is this?

JavaScript, as implemented by your browser. PCRE, used by PHP and grep -P, and RE2, used by Go, differ on lookbehind, on possessive quantifiers and on Unicode property escapes. A pattern that works here is not guaranteed to work there.

The page froze while I was typing a pattern.

Some patterns backtrack catastrophically on certain input — nested quantifiers such as (a+)+ are the classic case. The search over the whole text is bounded and gives up with a warning, but a single match that runs away cannot be interrupted by anything on the page: JavaScript has no way to stop a regular expression once it has started. Reload the tab, and treat it as a finding rather than an accident: the same expression on a server would take a worker with it.

Do I include the slashes?

No. Write the pattern on its own and put the flags in the flags field. Pasting /abc/gi as the pattern makes the slashes part of what you are matching.

Is my test string sent anywhere?

No, and it is deliberately excluded from the shareable link as well. Copying the link shares the pattern and the flags, never the text you tested against.

Good to know

  • Patterns are never executed on the server. A visitor-supplied expression that backtracks badly would be a denial of service there; in a tab it costs nothing but the tab.

Sources

All Code tools