Regex Tester
Test JavaScript regular expressions with live match highlighting, capture group inspection, and replace mode. Runs entirely in your browser.
What is a Regular Expression?
A regular expression (regex or regexp) is a compact language for describing patterns in text. Regexes are used for validation (email, phone, postcode), extraction (parsing logs, scraping data), and substitution (find & replace). Every major programming language and text editor has built-in regex support.
This tester uses the JavaScript RegExp engine — the same one running in Node.js and every modern browser. Patterns are compiled and executed entirely in your browser; nothing is sent over the network.
Common Regex Patterns
- Email (loose):
\b[\w.+-]+@[\w-]+\.[\w.-]+\b - IPv4:
\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b - URL:
https?://[^\s)]+ - UUID:
[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} - ISO date:
\d{4}-\d{2}-\d{2} - Hex color:
#[0-9a-f]{3,8}\b
Quick Syntax Reference
.any char (except newline, unlesssflag) ·\d \w \sdigit/word/whitespace ·\D \W \Snegations^ $start/end of string (or line withm) ·\bword boundary* + ?0+, 1+, 0-or-1 ·{n} {n,} {n,m}counted · add?for lazy (e.g..*?)[abc]any of ·[^abc]none of ·[a-z]range(abc)capture ·(?:abc)non-capture ·(?<name>abc)named ·\1backreference(?=...)lookahead ·(?!...)negative ·(?<=...)lookbehind ·(?<!...)negative
Avoiding Catastrophic Backtracking
Patterns with nested quantifiers over overlapping characters — like (a+)+ or (\w+)*$ — can hit exponential time on certain inputs and freeze your browser. Prefer atomic structure: rewrite (\w+)* as \w*, and avoid alternations where both branches can match the same text.
Frequently Asked Questions
RegExp object). Most syntax is portable to PCRE, Python re, and Go regexp, but a few features differ — JavaScript supports lookbehind only in modern engines, does not support possessive quantifiers, and uses different named-group syntax than PCRE.g = global (find all matches, not just the first); i = case-insensitive; m = multiline (^ and $ match line boundaries); s = dotall (. matches newlines too); u = unicode (full Unicode support, required for \p{} property escapes); y = sticky (match must start at lastIndex).(a+)+ or (a|a)* on long strings can cause exponential time complexity. The tester applies your regex synchronously, so a pathological pattern will freeze the tab. Avoid nested quantifiers over the same character class.(\d{4})-(\d{2})-(\d{2}) captures year, month, and day as groups 1, 2, 3. Use (?<name>...) for named groups. In the replace field, reference them as $1, $2, or $<name>.RegExp engine. Nothing is sent to any server.