Regex Tester
Test JavaScript regular expressions with live matches and capture groups.
Data is processed only in your browserHow to use
Regex Tester lets you test and debug JavaScript regular expressions in real time. Enter a regex pattern and test text, and the tool immediately highlights all matches with detailed capture group information.
How to use: Enter your regex pattern in the regex input (no surrounding slashes needed), and flags in the Flags box (e.g. g, i, m). Paste the test text below.
Common Regex Patterns
| Purpose | Pattern | Match Example |
|---|---|---|
[w.-]+@[w.-]+.w+ | user@example.com | |
| Phone (US) | d{3}[-.]?d{3}[-.]?d{4} | 123-456-7890 |
| IPv4 | d{1,3}.d{1,3}.d{1,3}.d{1,3} | 192.168.1.1 |
| Date (YYYY-MM-DD) | d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]d|3[01]) | 2024-01-15 |
| HTML Tag | <([a-z]+)([^<]*)(?:>(.*)</\1>)? | <div>content</div> |
Regex Syntax Reference
| Syntax | Meaning | Example |
|---|---|---|
. | Any character (except newline) | a.b → acb, axb |
d / w / s | Digit / Word char / Whitespace | d+ → 123 |
[abc] | Character set | [aeiou] → vowels |
(group) | Capturing group | (d+)-(w+) |
(?:group) | Non-capturing group | (?:http|https) |
(?<name>...) | Named capturing group | (?<year>d{4}) |
^ / $ | Start / End of line | ^hello$ |
* / + / ? | 0+ / 1+ / 0 or 1 times | ab*c |
{n,m} | n to m times | d{2,4} |
Flags Reference
g— Global match, find all matchesi— Case-insensitivem— Multiline, ^ and $ match each line boundarys— Dotall, . matches all characters including newline
Frequently asked questions
Which regex syntax is supported?
The tool uses the JavaScript regex engine, supporting most Perl-compatible features including capture groups, lookaheads, lookbehinds, and backreferences.
How do I test global matching?
Add the g flag in the Flags input to enable global matching. The tool will highlight all matches in the test string.
How do I view capture groups?
Match results display each capture group's content. Named groups (?<name>...) show both the group name and value, making complex regex debugging easier.