Test patterns with live matching, explanations, and code generation
Test regular expressions with live matching, explanations, and code generation
Flags modify how a regular expression matches text. They appear after the closing slash in regex literals (e.g., /pattern/gi). Here's what each flag does:
gFind all matches in the string, not just the first one. Without this flag, the regex stops after the first match.
iMatch letters regardless of case. For example, /hello/i matches "Hello", "HELLO", and "hello".
mMakes ^ match the start of each line and $ match the end of each line, not just the start and end of the entire string.
sMakes the dot (.) match any character including newline characters (\n). By default, dot matches everything except newlines.
uEnables full Unicode support. Correctly handles surrogate pairs and allows Unicode property escapes like \p{Letter}.
yMatches only at the exact position indicated by the lastIndex property. Useful for tokenizing or parsing input character by character.
These are the most frequently used regex patterns. The built-in pattern library in the tool has 20+ patterns you can load with one click.
| Pattern Name | Regex |
|---|---|
| Email Address | [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} |
| URL | https?://[\w.-]+(?:\.[\w.-]+)+[\w.,@?^=%&:/~+#-]* |
| IPv4 Address | \b(?:\d{1,3}\.){3}\d{1,3}\b |
| Phone Number | \+?\d{1,3}[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9} |
| Date (YYYY-MM-DD) | \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) |
| Hex Color | #(?:[0-9a-fA-F]{3}){1,2}\b |
| HTML Tag | <([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>.*?</\1> |
| Strong Password | (?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,} |
Quantifiers like *, +, and ? are greedy by default — they match as much text as possible. This often causes unexpected results when parsing HTML or quoted strings. Add ? after the quantifier to make it lazy (match as little as possible).
Characters like . * + ? ^ $ { } [ ] ( ) | \ have special meaning in regex. To match them literally, prefix with a backslash. For example, use \. to match a period, \$ to match a dollar sign, and \\ to match a backslash.
By default, ^ and $ match only the very start and end of the entire input string. Enable the multiline flag (m) to make them match at the start and end of each line. If you also need . to match newline characters, enable the dotall flag (s).
Your regex patterns and test strings are processed entirely in your browser. Unlike other online testers that send your data to servers, we never upload anything. This makes it safe to test patterns against log files, API keys, or any confidential text.
Enter your regex pattern in the pattern field, set any flags (global, case-insensitive, etc.), and paste your test text. Matches are highlighted in real-time as you type. The results panel shows each match with its position and any captured groups.
Regex flags modify how the pattern matches. Global (g) finds all matches instead of just the first. Case-insensitive (i) ignores letter case. Multiline (m) makes ^ and $ match line boundaries. Dotall (s) makes . match newlines. Unicode (u) enables full Unicode matching. Sticky (y) matches only at the current position.
Use parentheses to create capture groups: (pattern). For named groups, use (?<name>pattern). The results panel shows each group's matched text and position. You can reference groups in replacements with $1, $2, etc., or $<name> for named groups.
Yes. The code generator produces ready-to-use regex code for JavaScript, Python, Go, and Java, with proper escaping and language-specific syntax. Each generated snippet includes the pattern, flags, and a working example.
Greedy quantifiers (*, +, ?) match as much text as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, given '<b>bold</b>', the pattern <.*> greedily matches the entire string, while <.*?> lazily matches just <b>. Add ? after a quantifier to make it lazy.
Yes. All regex processing happens 100% in your browser. Your patterns and test data are never sent to any server. This makes it safe to test patterns against sensitive text like log files, API responses, or personal data.
Special regex characters (. * + ? ^ $ { } [ ] ( ) | \) must be escaped with a backslash to match literally. For example, to match a period, use \. instead of just a period. To match a backslash itself, use \\.
The built-in pattern library includes 20+ ready-to-use patterns for email validation, URLs, phone numbers, IP addresses (IPv4 and IPv6), dates, passwords, credit card numbers, HTML tags, hex colors, and more. Click any pattern to load it into the tester.