Regex Tester

Test JavaScript regular expressions against any string and see matches highlighted live. Capture groups, flags and match positions are listed below the result.

Uses the browser's native RegExp, so what you test here is exactly what your JavaScript code will run.

Highlighted

Highlighted matches will appear here.

Matches

Match list with capture groups will appear here.
Edit the pattern or test string, then press Test (Cmd/Ctrl+Enter).

JavaScript flavor

This tester uses the browser's built-in RegExp. It supports ECMAScript regex syntax, which is not the same as PCRE (PHP, Perl) or Python re. Some constructs you may know from other engines are not available or behave differently:

  • No possessive quantifiers (a*+, a++).
  • No atomic groups (?>...).
  • No conditional patterns (?(1)yes|no).
  • Lookbehind (?<=...) is supported in modern browsers but can fail in older engines.
  • Named groups use (?<name>...) (not (?P<name>...) like Python).

Flags reference

  • g — return all matches, not just the first.
  • i — case-insensitive match.
  • m^ and $ match at line breaks, not only string edges.
  • s — dot . also matches newlines.
  • u — full Unicode mode; \p{...} property escapes enabled.
  • y — sticky: match must start exactly at lastIndex.

Examples

A few patterns you can paste into the field above to see them work:

\d{4}-\d{2}-\d{2}            # ISO-like dates
[\w.+-]+@[\w-]+\.[\w.-]+     # rough email
^https?:\/\/\S+              # URL at line start (needs m flag)
(?<year>\d{4})-(?<mo>\d{2})  # named groups

FAQ

Why does my pattern that works in PHP/Python fail here?

This tester runs your pattern through the browser's RegExp, which is ECMAScript flavor. PCRE-only features (possessive quantifiers, atomic groups, conditional patterns) are not supported. Rewrite the pattern in ECMAScript-compatible form.

My pattern made the page freeze for a moment. Why?

JavaScript's regex engine is single-threaded and can be slow on patterns with catastrophic backtracking (e.g. nested quantifiers like (a+)+$). The tool caps the match list at 1000 to limit the damage, but the regex match itself runs in the page.

How do I match across multiple lines?

Use the s flag if you want . to also match newlines, and the m flag if you want ^/$ to anchor to each line.

Are my pattern and test text sent anywhere?

No. The regex runs entirely in your browser. Nothing is uploaded.

Related tools