Free Regex Tester
Test regular expressions with live match highlighting, capture group inspection and replace preview. Supports every JavaScript flag — all in your browser.
Pattern & Test String
$1, $& and $<name> in the Replace tab.Results
What Is a Regular Expression?
A regular expression (regex) is a mini-language for describing patterns in text. Instead of searching for a literal string like "hello", you write a pattern that matches any text fitting a rule — for example, \b\w+@\w+\.\w+\b matches any email address.
Regex is built into every major programming language and used everywhere: form validation, log parsing, search-and-replace, text editors, command-line tools like grep and sed, and even your browser's Find bar supports basic patterns.
The building blocks
| Syntax | Matches |
|---|---|
| abc | The literal text "abc" |
| . | Any single character except newline |
| \d | Any digit 0–9 |
| \w | Any word character (letter, digit, underscore) |
| \s | Any whitespace (space, tab, newline) |
| [abc] | Any one of a, b or c |
| [^abc] | Any character except a, b or c |
| a* | Zero or more a's |
| a+ | One or more a's |
| a? | Zero or one a |
| a{3} | Exactly 3 a's |
| a{2,5} | Between 2 and 5 a's |
| ^ | Start of string (or line with m flag) |
| $ | End of string (or line with m flag) |
| \b | Word boundary |
| (abc) | Capture group — captures "abc" |
| (?:abc) | Non-capturing group |
| (?<name>abc) | Named capture group |
| a|b | a or b (alternation) |
The flags
| Flag | Effect |
|---|---|
| g | Global — match all occurrences, not just the first |
| i | Ignore case — "Hello" and "hello" match the same |
| m | Multiline — ^ and $ match line boundaries too |
| s | dotAll — . also matches newline characters |
| u | Unicode — full Unicode matching, required for astral-plane characters and properties like \p{Emoji} |
| y | Sticky — matches only from the regex's lastIndex position |
Capture groups and backreferences
Parentheses create capture groups. In a replacement string:
$&— the entire match$1,$2— group 1, group 2, etc.$<name>— a named group defined with(?<name>…)$`— the text before the match$'— the text after the match$$— a literal dollar sign
The three regex flavours
| Flavour | Used by | Notes |
|---|---|---|
| JavaScript | Browsers, Node.js | What this tool uses. ECMAScript spec. |
| PCRE | PHP, grep -P, many others | Most feature-complete flavour. Adds recursion, atomic groups. |
| RE2 | Go, Rust, re2 | Linear-time engine. No backreferences, no lookbehind. Very fast. |
Most patterns work identically across all three. The differences appear with advanced features like possessive quantifiers, variable-length lookbehind, and \p{...} Unicode properties (which JavaScript only supports with the u flag).
Catastrophic backtracking
Some patterns are correct but pathologically slow. The classic example is (a+)+b tested against 30 a's with no b at the end — the engine tries every possible combination of groupings, taking 2³⁰ steps. This can freeze a browser tab.
This tool guards against it by capping the number of steps and the test string length. If a regex is genuinely slow, it's usually a sign to rewrite it. The fix is often to remove nested quantifiers or replace (a+)+ with a+.
Common use cases
Form Validation
Verify email, phone, URL and postal codes before submission.
Log Parsing
Extract timestamps, IPs and error codes from log files.
Bulk Find & Replace
Rename variables or reformat text across many files at once.
Data Extraction
Pull emails, phone numbers or URLs out of unstructured text.
Code Refactoring
Find all function calls, imports, or comments matching a pattern.
Data Cleaning
Normalise messy CSV columns or strip unwanted characters.
Learning Regex
Experiment with patterns and see exactly what they match.
Debugging Patterns
Trace why a regex matches more or less than expected.
Privacy and security
This regex tester runs entirely in your browser. Matching uses the native JavaScript RegExp engine — the same one your code will use at runtime. Your pattern and your test string never leave your device, safe for internal data, proprietary formats and confidential text.
Frequently Asked Questions
What is a regex tester?
Which regex flavour does this tool use?
RegExp engine — the same one used by every modern browser. This is very close to the regex support in Node.js, and compatible with most patterns from other languages, though there are small differences in look-behind and named groups between flavours.What do the flags mean?
^ and $ match the start and end of each line. s (dotAll) makes . match newlines too. u (unicode) enables full Unicode matching for characters outside the BMP. y (sticky) matches only from the lastIndex position.What is catastrophic backtracking?
(a+)+b takes exponentially longer to fail on certain inputs. It can freeze the browser. This tool caps the number of steps and test string length to protect against it, but the real fix is to rewrite the regex — usually by avoiding nested quantifiers.How do capture groups work?
$1, $2, and so on. Named groups use (?<name>…) and are referenced as $<name>. The full match is always $&.Can I use named capture groups?
(?<name>pattern) and reference the group as $<name> in the replace string. Named groups also appear in the match list under their name.