Regex Tester
Test JavaScript regular expressions in real time. Matches are highlighted inline. Supports global, case-insensitive, multiline, and dotAll flags.
Regular Expression
Test String
Match Preview
Contact us at support@example.com or sales@company.org.
Visit https://devtoolshub.dev for more tools.
Server IP: 192.168.1.100. Color: #ff6347.FAQ
Which regex flavor does this use?▼
This tool uses JavaScript (ECMAScript) regular expressions via the built-in RegExp engine. Most patterns are compatible with JavaScript, Python, and other languages, but some advanced features like lookbehinds may differ.
Why does my match loop infinitely?▼
Zero-length matches with the global flag can cause infinite loops. This tool automatically advances lastIndex when a zero-length match is found to prevent this.
What does the 's' (dotAll) flag do?▼
Without the dotAll flag, the . metacharacter does not match newline characters. The s flag makes . match any character including \n.
Frequently Asked Questions
Which regex flavor does this tool use?
JavaScript (ECMAScript) regular expressions — the same engine used in Node.js and all modern browsers. Supports ES2018+ features including named capture groups and the s (dotAll) flag.
What does the g flag do?
The g (global) flag makes the regex find all matches in the string instead of stopping after the first match. Essential for replace-all operations and counting total occurrences.
What are capture groups?
Capture groups, created with parentheses ( ), let you extract specific parts of a match. Named groups (?<name>...) give each group a descriptive label accessible via match.groups.name.
What is a Regular Expression?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. They are used to find, validate, extract, or replace text that matches the pattern. Regex is supported natively in JavaScript, Python, Java, Go, Ruby, Rust, PHP, and most other programming languages.
Common use cases include: validating email addresses, phone numbers, and postal codes; extracting data from logs; replacing text in bulk; parsing structured data like URLs or markdown; and building lexers and parsers.
Quick Regex Reference
| Pattern | Meaning | Example match |
|---|---|---|
| . | Any character except newline | a, b, 1, @ |
| \d | Digit (0–9) | 0, 5, 9 |
| \w | Word char (letter, digit, _) | a, Z, 3, _ |
| \s | Whitespace (space, tab, newline) | , \t |
| ^ | Start of string | First char |
| $ | End of string | Last char |
| * | 0 or more of previous | aaa, a, "" |
| + | 1 or more of previous | aaa, a (not empty) |
| ? | 0 or 1 of previous (optional) | colour / color |
| {n,m} | Between n and m repetitions | {2,4} → aa, aaa |
| [abc] | Any one of a, b, c | a, b or c |
| [^abc] | Any character except a, b, c | d, e, 1 |
| (abc) | Capture group | extracts 'abc' |
| (?:abc) | Non-capturing group | groups without capture |
| (?<n>abc) | Named capture group | match.groups.n |
| a|b | Alternation (a or b) | a or b |
JavaScript Regex Flags
g — globalFind all matches, not just the first one. Required for replace-all and counting total occurrences.
i — case-insensitiveMatch regardless of letter case. /hello/i matches 'Hello', 'HELLO', 'hElLo'.
m — multiline^ and $ match the start/end of each line instead of the whole string.
s — dotAllMakes . match newline characters too. Without s, a dot skips line breaks.
u — unicodeEnables full Unicode support. Required for matching emoji and non-BMP code points correctly.