Regex Tester
Test JavaScript regular expressions against sample text with live highlighting, capture groups and match positions.
Useful patterns to start from
| Purpose | Pattern |
|---|---|
| Email (basic) | [\w.+-]+@[\w-]+\.[\w.]+ |
| IPv4 address | \b(?:\d{1,3}\.){3}\d{1,3}\b |
| URL | https?:\/\/[^\s]+ |
| ISO 8601 date | \d{4}-\d{2}-\d{2} |
| Hex colour | #(?:[0-9a-fA-F]{3}){1,2}\b |
| Whitespace trim | ^\s+|\s+$ |
| Repeated word | \b(\w+)\s+\1\b |
| HTML tag | <\/?([\w-]+)[^>]*> |
JavaScript regex flags
| Flag | Name | Effect |
|---|---|---|
g | global | Find every match rather than stopping at the first |
i | ignore case | Match regardless of letter case |
m | multiline | Make ^ and $ match at line breaks |
s | dotAll | Allow . to match newline characters |
u | unicode | Enable full Unicode matching and \p{...} classes |
Beware catastrophic backtracking. Nested quantifiers such as
(a+)+$ can require exponential time on non-matching input, freezing the browser tab.
If this page becomes unresponsive, your pattern has this problem — prefer possessive-style rewrites or
atomic alternatives.
Privacy. Matching runs in your browser. Neither pattern nor test text is uploaded anywhere, so you can safely paste real log data to debug an expression.
Frequently asked questions
Which regex flavour is supported?
JavaScript (ECMAScript), because matching uses your browser's own engine. Lookbehind and named capture groups are supported in all current browsers; older engines such as Safari before 16.4 lack lookbehind.
Why do I see zero matches with the g flag?
Ensure the flag is genuinely enabled. Without g, only the first match is returned. Another common cause is a pattern containing a ^ anchor when your sample starts with leading spaces.
How do I match across line breaks?
Enable the s flag so . matches newlines, or use [\s\S] instead of . for maximum compatibility with older engines.
Can I use this for replacement / substitution?
This page focuses on matching and inspection. In JavaScript, substitution is done with String.prototype.replace() together with tokens such as $1 and $&.
Do you support named capture groups?
Yes. Write them as (?<name>...) and enable the u flag if you use Unicode property escapes alongside them.