Regex Tester
Test regular expressions online with live match highlighting. Try patterns against sample text, inspect capture groups, and preview find-and-replace results instantly.
JavaScript regex flags cheat sheet
| Flag | Name | Effect |
|---|---|---|
g | global | Find all matches, not just the first |
i | ignoreCase | Case-insensitive matching |
m | multiline | ^ and $ match line boundaries, not just string boundaries |
s | dotAll | . also matches newline characters |
u | unicode | Treats the pattern as a sequence of Unicode code points |
Common pattern examples
| Purpose | Pattern |
|---|---|
| Email address | ^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$ |
| URL | https?:\/\/[^\s]+ |
| Digits only | ^\d+$ |
| UUID | ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ |
| HTML tag | <([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>) |
Frequently asked questions
How do I test a regex online?
Type a pattern into the field above the test string. Matches are highlighted live as you type, with no need to click a button.
How do I use capture groups in the regex tester?
Wrap part of your pattern in parentheses, for example (\d+). Each match's capture groups are listed below the highlighted text.
What is the difference between the g flag and no flag?
Without the g (global) flag, a regex stops after finding the first match. With g, it finds every non-overlapping match in the string. This tool respects your chosen flags exactly, so unchecking g will show only the first match, matching real JavaScript behavior.
What do the i, m and s flags do?
i makes matching case-insensitive. m makes ^ and $ match the start/end of each line rather than the whole string. s (dotAll) makes . also match newline characters, which it doesn't by default.
Is JavaScript regex the same as PCRE or Python regex?
Mostly similar but not identical. JavaScript regex has its own syntax for named groups, lookbehind support varies by engine version, and some features common in PCRE (like atomic groups or possessive quantifiers) aren't supported. This tool runs your pattern through the actual browser JavaScript engine, so results match what you'd get in real JS code.