How to test a regular expression
- Type your pattern without the surrounding slashes, for example \d{3}-\d{4}.
- Choose the flags you need: g (on by default), i, m or s.
- Paste the text to search in the test box.
- Matches are highlighted as you type. The match details list each match with its position and the values of its capture groups.
Regex flags explained
- g (global): find every match instead of stopping at the first one.
- i (case insensitive): treat uppercase and lowercase letters as equal.
- m (multiline): make ^ and $ match at the start and end of each line, not only of the whole text.
- s (dotAll): let . match line breaks too.
Useful patterns to start from
These patterns are practical starting points. Adjust them to your data, and remember that validating formats like email addresses fully with a regex is rarely worth it.
\d+ one or more digits
^\s*$ an empty or whitespace-only line (use the m flag)
\b\w+@\w+\.\w{2,}\b a simple email-like string
\d{4}-\d{2}-\d{2} a date like 2026-11-14
(?<year>\d{4})-(?<month>\d{2}) named capture groups
https?://[^\s]+ a URL starting with http or https
#[0-9a-fA-F]{6}\b a hex color like #0579D0JavaScript regex flavor
The tester uses the JavaScript (ECMAScript) regular expression engine built into your browser, the same one used by Node.js and every frontend framework. Patterns that work here work in your JavaScript and TypeScript code.
Modern browsers support lookahead, lookbehind, named groups and Unicode property escapes. JavaScript does not support possessive quantifiers, atomic groups or inline modifiers like (?i), which exist in other flavors such as PCRE.
Frequently asked questions
- Which regex flavor does this tester use?
- JavaScript (ECMAScript), running in your browser. Results match what RegExp does in Chrome, Firefox, Safari, Edge and Node.js.
- Will my Python or PHP regex work here?
- Most everyday patterns behave the same. Differences appear with flavor-specific features: for example, Python uses (?P<name>...) for named groups while JavaScript uses (?<name>...), and PHP supports possessive quantifiers that JavaScript does not.
- Why is only the first match highlighted?
- Without the g (global) flag a regular expression stops at the first match. The g flag is on by default; if you turned it off, turn it back on to find every match.
- Why does . not match line breaks?
- By default the dot matches any character except line terminators. Turn on the s (dotAll) flag, or use [\s\S] in your pattern, to include them.
- My pattern makes the page freeze. Why?
- Patterns with nested quantifiers, such as (a+)+, can take exponential time on some inputs. This is called catastrophic backtracking. Make quantified parts more specific or remove the nesting.
- Is the text I test sent anywhere?
- No. Matching runs in your browser and nothing is uploaded or stored, so you can safely test patterns against logs and real data.