Match count
0
Free · Instant · No signup
JavaScript regex flags, match table with groups, presets, and a 20k ReDoS cap.
Match count
0
Execution time
0.00 ms
Match details
| Index | Start | End | Full match | Groups |
|---|---|---|---|---|
| No matches yet. | ||||
Most "regex testers" are fine until the sample is a customer dump or an access log. This page compiles new RegExp(pattern, flags) in your tab. Invalid syntax goes to an assertive alert. Valid syntax walks the test subject and fills a table: match index, start and end character offsets, the full match, and capture groups (numbered, plus named groups when present).
Flag buttons are g, i, m, s, u, and y. Global is on by default so you see every match, not only the first. Sticky (y) still respects lastIndex. DotAll (s) lets . consume newlines. Unicode (u) is required for some property escapes. Mix them the way the JS engine allows. Illegal combinations fail at compile time and show in the alert.
new RegExp(pattern, flags)test.slice(0, 20000)performance.now() around exec
Execution time is milliseconds for the match loop, not for rendering the table. Zero-width matches increment lastIndex so /a*/g cannot spin forever. A hard ceiling of 5,000 matches stops a pathological global pattern from building a million table rows.
Catastrophic backtracking is a real way to freeze a tab. Nested quantifiers plus a long subject are the usual recipe. This tester slices the subject to 20,000 characters and notes the truncation in a polite status region. That is a brake, not a rewrite of the engine. Keep experimental patterns on short samples.
Presets: Email, URL, IPv4, Phone number, ISO date. They are starters. Email is not RFC 5322. IPv4 rejects 999.1.1.1 via 0-255 octets. ISO date is YYYY-MM-DD digits, not a check that 2026-02-31 is invalid. Edit after load. Load email sample is the same as choosing the Email preset.
Do not wrap the pattern in slashes. Flags live on the buttons, not in the text field. A pattern of /foo/gi will look for a literal slash. If you need to pretty-print JSON that a regex extracted, paste it into the JSON Formatter and Minifier.
This is JavaScript RegExp as implemented by the current browser. It is not PCRE, not Python re, not Go RE2, and not POSIX. Lookbehind works where the browser supports it. Possessive quantifiers do not. If production is RE2 (many gateways), a pattern that works here can still be rejected there. Copy the pattern into the runtime you ship.
Clear empties pattern and subject and restores flag g. For Base64 payloads rather than regex, use the Base64 Encoder and Decoder. For crontab rather than regex, use the Cron Expression Generator.
new RegExp throws. The message is copied into a live alert (assertive). Match count stays 0 and the table says the pattern did not compile. Fix the syntax (unclosed group, dangling backslash, bad flag combo) and the table updates on the next input event.
The test subject is sliced to 20,000 characters before exec. Nested quantifiers on long input can freeze a tab (ReDoS). The cap is a hard stop, not a proof that every pattern is safe. Pathological patterns can still be slow under the cap. Keep samples short when you experiment with .* and nested plus.
The six JavaScript flags this page exposes: g (global), i (case-insensitive), m (multiline ^ $), s (dotAll, dot matches newline), u (Unicode), y (sticky). Without g, only the first match is listed. With g, exec walks until there are no more matches, with a 5,000 match ceiling.
They are starter patterns, not full RFCs. Email is a practical local@domain check, not RFC 5322. URL looks for http(s) prefixes. IPv4 uses 0-255 octets. Phone is a loose digit run with optional +. ISO date is YYYY-MM-DD digits only, not a calendar validator.