Matches
| # | Index | Match | Groups |
|---|---|---|---|
|
|
About the Regex Tester
This tester runs your pattern with the browser's JavaScript RegExp engine, so results match what your JavaScript code will do. Matches are highlighted in the test string as you type, and a table lists each match with its index, numbered capture groups ($1, $2, ...) and named groups ((?<name>...)). A replace panel previews String.prototype.replace with $1, $<name> and $& in the replacement.
Toggle the flags g (global), i (ignore case), m (multiline, so ^ and $ match at line breaks), s (dotAll, so . matches newlines), u (Unicode) and y (sticky). Everything runs locally.
How to use it
- Type a pattern between the slashes; no need to escape
/. - Pick flags.
- Paste text into the test string and review the highlighted matches and groups.
- Optionally enter a replacement to preview the result.
Examples
Pattern: (\w+)@(?<domain>[\w-]+\.[\w.]+) flags: g
Text: Contact alice@example.com or bob@mail.example.org
Matches: alice@example.com ($1 = alice, domain = example.com)
bob@mail.example.org ($1 = bob, domain = mail.example.org)
Replacement: $1 at $<domain>
Result: Contact alice at example.com or bob at mail.example.org
Common questions
Why does it only find the first match?
Without the g flag, JavaScript stops after the first match. Turn on g to find all of them.
Is this the same as PCRE or Python regex?
Mostly, but not entirely. JavaScript has no possessive quantifiers, atomic groups or inline modifiers like (?i), and it writes named groups as (?<name>...) rather than Python's (?P<name>...).
Why does . not match a line break?
By default . excludes line terminators. Enable the s (dotAll) flag, or use [\s\S].
What does the u flag do?
It treats the pattern as Unicode code points, so emoji and other astral characters count as one character, and it enables \p{...} property escapes such as \p{L}.
Related tools
- Text Diff Checker: compare text before and after a replace.
- Data Anonymizer: mask emails, IPs and tokens without writing patterns.
- Case Converter: change the case of matched identifiers.