Regex Tester
Write a regular expression and test it against any string. Matches highlight live, capture groups and named groups are shown per-match. Supports all JavaScript regex flags and a replace mode with backreferences.
Common patterns
Ready-to-use patterns — click any row to copy the regex
| Name | Pattern |
|---|---|
[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} | |
| URL | https?:\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])? |
| IPv4 | \b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b |
| ISO date | \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) |
| Hex color | #(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b |
| JWT token | eyJ[A-Za-z0-9_\-]+\.eyJ[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+ |
| Semver | \bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.]+)?\b |
| UUID | [0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12} |
JavaScript regex flags
/gglobalFind all matches in the string, not just the first. Required for matchAll().
/iignoreCaseMatch regardless of uppercase or lowercase. 'abc' matches 'ABC', 'Abc', etc.
/mmultilineMakes ^ match the start of each line and $ match the end of each line, not just the whole string.
/sdotAllMakes . match any character including newlines (\n). Without this, . skips line breaks.
/uunicodeEnables full Unicode matching. Required for \p{} Unicode property escapes and for correctly matching supplementary plane characters like emoji.
Frequently asked questions
What is the difference between .test() and .exec() in JavaScript?
test() returns a boolean — true if the regex matches anywhere in the string. exec() returns the match object (or null) including the full match, capture groups, and index. For global regexes, exec() must be called in a loop to get all matches; test() just tells you if any match exists.
Why does my global regex infinite-loop in JavaScript?
When you call regex.exec() in a loop with a global regex, the regex's lastIndex advances after each match. If a match has zero length (e.g., /a*/ matching an empty position), lastIndex doesn't advance and the loop runs forever. Always check for zero-length matches and increment lastIndex manually, or use String.matchAll() which handles this automatically.
What are named capture groups?
Named groups use the syntax (?<name>pattern). Instead of accessing captures by index ($1, $2), you use the name: $<name> in replacement strings or match.groups.name in code. They make complex patterns much more readable and are supported in modern JavaScript (ES2018+).
What is a lookahead / lookbehind?
Lookaheads and lookbehinds are zero-width assertions. Positive lookahead (?=...) matches a position followed by the pattern. Negative lookahead (?!...) matches a position NOT followed by it. Lookbehinds (?<=...) and (?<!...) work the same way but look behind the current position. They don't consume characters — useful for matching context without including it in the result.
Why does \d not match non-ASCII digits?
Without the u flag, \d only matches ASCII digits 0–9. It will not match Arabic-Indic digits (٠١٢…) or other Unicode numeric characters. With the u flag and \p{Nd} (Unicode property escape), all Unicode decimal digits are matched.
Related Tools
All conversions run in your browser — nothing is uploaded.
Browse all 26 converters →