Test JavaScript regular expressions with real-time matching, capture groups, named groups, and replace. 100% browser-based — no data sent anywhere.
Enter a pattern above and test string to see matches.
g (global — find all), i (ignore case), m (multiline), s (dot-all), u (unicode).$1, $2, or $<name> for named groups.Regular expressions (regex) are powerful pattern-matching sequences used to search, validate, extract, and transform text. JavaScript's built-in RegExp engine — which powers this tester — supports the full ECMAScript regex standard including named capture groups ((?<name>...)), lookbehind assertions ((?<=...)), Unicode property escapes (\p{L} with the u flag), and sticky matching. This tool runs every match operation entirely in your browser using native JavaScript — your test strings and patterns never leave your device. It is ideal for debugging API response parsing, building form validation, writing log analysis scripts, or learning regex syntax with immediate feedback. Use the common patterns quick-load bar above the pattern field to get started with frequently needed patterns like email addresses, URLs, IPv4 addresses, dates, and UUIDs.
This happens when the pattern contains a syntax error. Common causes include unmatched or unescaped parentheses, an invalid quantifier like {,3}, unescaped forward slashes inside a character class, or an invalid escape sequence such as \q. Make sure to escape literal dots with \., backslashes with \\, and parentheses with \( when you need them as literal characters rather than metacharacters.
Wrap the part of the pattern you want to capture in parentheses: (\d{4})-(\d{2})-(\d{2}) captures year, month, and day as groups 1, 2, and 3. In the Replace field, reference them with $1, $2, $3. For named groups like (?<year>\d{4}), use $<year> in the replacement. Use $& to insert the entire matched substring.
The g (global) flag makes the engine find all non-overlapping matches in the input string instead of stopping after the first one. The m (multiline) flag changes the meaning of ^ and $ — without m they match the start and end of the entire string; with m they match the start and end of each individual line. You often combine both flags when processing multi-line text with line-based patterns.
Yes. Modern JavaScript (V8 engine) supports all four zero-width assertions: positive lookahead (?=...), negative lookahead (?!...), positive lookbehind (?<=...), and negative lookbehind (?<!...). For example, \w+(?=\.js\b) matches filenames immediately before a .js extension, and (?<=\$)\d+(\.\d{2})? matches a dollar amount after the $ sign without including the sign in the match.