JavaScript Regex Tester โ All Flags ยท Groups ยท Replace ยท matchAll
Real-time ยท 26 features ยท AI explain ยท Unit tests ยท Diff mode ยท JS/Python/PHP ยท 100% browser
Test JavaScript regular expressions with all native JS features. All 6 flags (g/i/m/s/u/y), matchAll iteration, named groups, String.replace with backreferences, and ready-to-paste JS code snippets.
What is a Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Used for validation, parsing, text manipulation, and data extraction in virtually every programming language โ JavaScript, Python, PHP, Java, and more.
How to Use This Regex Tester
Type your regex pattern in the input field. Matches highlight in real-time in the test text panel. Use the flags (g/i/m/s/u/y) to modify matching behavior. Switch between Test, Replace, Unit Test, Diff, and Multi-string modes using the tabs above.
Frequently Asked Questions
What regex flags does JavaScript support?
JavaScript supports 6 flags: g (global), i (case-insensitive), m (multiline), s (dotAll โ . matches newline), u (unicode), y (sticky โ match from lastIndex). This tester supports all 6.
How do named capture groups work in JavaScript?
Use (?<name>...) syntax. Access via match.groups.name or in replace with $<name>. Example: /(?<year>\d{4})-(?<month>\d{2})/ โ match.groups = { year: "2024", month: "01" }
What is the difference between match() and matchAll()?
str.match(regex) with /g returns an array of strings. str.matchAll(regex) returns an iterator of full match objects with index, groups, etc. This tool uses matchAll internally to show all match details.
What does the s (dotAll) flag do?
By default, . does not match newline (\n). With the s flag, . matches ANY character including newlines. Useful for matching multi-line strings like HTML tags or log entries.
What is the y (sticky) flag?
The sticky flag makes the regex match only from lastIndex. Unlike /g which searches the whole string, /y only tries to match at the exact current position. Used for parsing tokenizers.