Regex Tester
Test JavaScript regular expressions against any text. Run test, match-all, replace, or split with full flag support (gimsuy), capture and named groups, and live results. Runs entirely in your browser.
JavaScript Regex Flag Reference
| Flag | Meaning | Example use |
|---|---|---|
| g | Find all matches | Replace every occurrence |
| i | Ignore case | Match A and a |
| m | Multiline anchors | Match each line start |
| s | Dot matches newlines | Match across lines |
| u | Unicode mode | Interpret Unicode escapes |
| y | Sticky matching | Match at the current index |
Frequently Asked Questions about the Regex Tester
Which regex flavor does this tester use?
It uses the JavaScript RegExp engine in your browser. Syntax and feature support therefore follow that browser's ECMAScript implementation and may differ from PCRE, Python, .NET, grep, or older JavaScript engines. Test the pattern in the same runtime where you plan to deploy it.
What do the g, i, m, s, u, and y flags do?
g (global) keeps the engine going after the first match, which match-all, replace-all, and split need. i (insensitive) ignores letter case, so /abc/i matches ABC and AbC. m (multiline) makes ^ and $ match at every line break, not only at the start and end of the whole string. s (dotall) lets the . metacharacter match a newline too. u (unicode) turns on full Unicode support so \u{1F600} and Unicode property escapes like \p{Letter} work. y (sticky) anchors the next match to the engine's lastIndex, useful for parsing tokens in sequence. The tester accepts any combination of those six and rejects any other character.
What is the difference between capture groups and named groups?
A capture group is anything inside plain parentheses, like (\d{4}). It is numbered left to right starting at 1, and you reference it by position: $1 in a replacement, m[1] on a match object. A named group adds a label with (?<name>...), so (?<year>\d{4}) gives you m.groups.year on the match and $<year> in the replacement. Named groups still keep their numeric index, so a year group at position 1 is reachable as either $1 or $<year>. Use names when a pattern has more than two or three groups, or when the meaning of a group is not obvious from its position.
What is catastrophic backtracking and how do I avoid it?
Catastrophic backtracking occurs when a pattern can retry the same text through exponentially many paths. Nested or overlapping quantifiers such as (a+)+ are common warning signs. The tester's length limits do not guarantee safety because a much shorter input can still stall the main thread. Do not test untrusted patterns here; use a runtime with enforceable timeouts or a non-backtracking engine.
When should I use replace versus match-all?
Use replace when you want a transformed copy of the input, like turning every email address into a hyperlink or stripping every HTML tag. Replace returns one string and a count of how many substitutions happened, and the replacement string can reference capture groups with $1, $<name>, and the special tokens $&, $`, $', and $$. Use match-all when you only need to extract data: every match, its index, and its groups arrive as a list you can iterate. Match-all needs the g flag (the tester adds it for you), and unlike replace it does not modify the input at all, which makes it the right tool for scanning, validation, and pulling structured fields out of free text.
Related Calculators
More calculators in "Tech"
MTU CalculatorWiFi Channel Overlap CalculatorIPv6 Subnet CalculatorHTML Character Entities Encoder/DecoderLevenshtein Distance CalculatorLuhn Checksum Calculator
See all 98 calculators in "Tech"