Free Online Regex Tester
Test and debug JavaScript regular expressions in your browser. See matches highlighted live, inspect capture groups, and preview replacements. Nothing is ever sent to a server.
Match Results
What is a Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Instead of looking for one fixed string, a regex describes the shape of the text you want — digits, words, email addresses, dates, and more. This makes pattern matching one of the most powerful tools for developers, data analysts, and sysadmins, who rely on it every day to validate input, search through logs, and transform text quickly and reliably.
JavaScript Regex Flags Explained
| g | global — find all matches in the string, not just the first one. |
| i | case-insensitive — letters match regardless of upper or lower case. |
| m | multiline — the anchors ^ and $ match the start and end of each line, not just the whole string. |
| s | dotAll — the dot . also matches newline characters. |
| u | unicode — enables full Unicode matching, including code points above U+FFFF. |
Common Regex Patterns Reference
| Pattern | Regex | Matches |
|---|---|---|
| /[^\s@]+@[^\s@]+\.[^\s@]+/ | hello@charcount.app | |
| URL | /https?:\/\/[^\s]+/ | https://charcount.app |
| IPv4 | /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/ | 192.168.0.1 |
| Date (YYYY-MM-DD) | /\d{4}-\d{2}-\d{2}/ | 2026-06-30 |
| Hex Color | /#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})\b/ | #4338ca |
| UUID v4 | /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab]…/i | 9f1c…5b6c |
Regex Capture Groups
Parentheses let you capture parts of a match so you can extract or reuse them. There are three kinds:
( )— a capturing group: stores what it matched, accessible as $1, $2, … in replacements.(?: )— a non-capturing group: groups the pattern for alternation or quantifiers without storing it.(?<name> )— a named group: captures with a readable name, accessible as groups.name.
For example, parsing a date with three groups: (\d{4})-(\d{2})-(\d{2})