PTBox

JavaScript Regular Expression Tester

JavaScript regular expression tester — shows all matches and capture groups in real time, with g / i / m / s / u / y flag toggles.

//gi
2 matches
#IndexMatchGroups
112[email protected]
233[email protected]

Usage

Tests JavaScript regular expressions (the ECMAScript regex engine). Supports the six flags g i m s u y, highlighting all matches in real time and listing capture groups.

JS regex differs from PCRE / Python in some details (lookbehind, named groups, etc.).

Use cases

Form validation

Debug regexes for email, phone, ID-card validation.

Log extraction

Pull IPs, URLs and timestamps from log lines.

Bulk string replacement

Verify a replace-regex precisely matches the intended substrings.

Learning regex

Highlighted matches plus capture groups make it easy to see how the regex consumes input.

FAQ

Which regex flavor is this?

JavaScript / ECMAScript. Differs from PCRE and Python in lookbehind, named groups and a few other details.

Are lookbehinds supported?

(?<=...) and (?<!...) work in all modern browsers; older Safari (<16.4) doesn't.

How do I write a named group?

(?<name>...). Access the value via match.groups.name. The tool shows named groups automatically.

Why does g flag affect test() between calls?

g-flag regexes have a lastIndex state; consecutive test() calls continue from the previous position. Reset lastIndex or reuse a fresh regex between calls.

Related tools

Comments

0 / 1000