Test JavaScript regular expressions with real-time match highlighting
Regular expressions (regex) are patterns for searching, validating and transforming text. In JavaScript they're natively supported via the match(), replace(), test() and matchAll() methods.
Flags change the behavior: g finds all matches (not just the first), i ignores case, m treats each line as a string start/end, s makes the dot also match newlines.
How do I validate an email with regex in JavaScript?
A reliable email regex is /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/. Regex can't guarantee 100% validity โ for that you need to send a verification email.
What are capture groups?
Parentheses () create groups that capture the matching part of the text. You can reference them with $1, $2... in replace, or read them with match()[1]. Non-capturing groups use (?:...).
This tool tests JavaScript regular expressions in real time, highlighting matches, captured groups, and active flags โ useful during development to validate patterns before using them in code.
Yes, the tool uses JavaScript's native regex engine: some syntax available in other languages (like lookbehinds in certain PCRE versions) may behave differently.
Groups captured by the regex are highlighted and listed separately from the full match, useful for checking that sub-part extraction works as expected.
No, both the regex and the test text are processed entirely in your browser, without being sent to a server.