Regex Tester
Test and debug regular expressions in real-time. Live match highlighting, group capture, find & replace, common patterns library. Free, instant, 100% browser-based.
Test String
Matches
What is a Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Regex is used in programming, text editors, and command-line tools to find, match, and manipulate text. It is one of the most powerful tools for string processing.
This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript specification. Results will match what you get in JavaScript, Node.js, and most modern browsers.
Regex Flags Explained
| Flag | Name | What it Does |
|---|---|---|
g | Global | Find all matches, not just the first one |
i | Case-insensitive | Match uppercase and lowercase letters equally (A matches a) |
m | Multiline | ^ and $ match start/end of each line, not just the string |
s | DotAll | Makes . match newline characters too (normally it doesn't) |
u | Unicode | Enable full Unicode matching (emoji, accented characters, etc.) |
y | Sticky | Match only at the exact position of lastIndex |
How to Use — 3 Simple Steps
Enter Your Pattern
Type your regex pattern in the input bar at the top. Toggle flags (g, i, m, etc.) by clicking them. Or choose a preset from the Patterns dropdown.
Add Your Test String
Paste or type the text you want to search in the left panel. Matches are highlighted instantly on the right as you type.
Explore Results
Switch to Details tab to see each match's index, length, and captured groups. Use Replace mode for find & replace with $1, $2 substitutions.
Common Regex Patterns
| Pattern | Description | Example Match |
|---|---|---|
\d+ | One or more digits | 42, 2024 |
\w+ | Word characters (letters, digits, underscore) | hello, user_123 |
[a-z]+ | Lowercase letters | abc, hello |
^.+$ | Entire line (with m flag) | Any complete line |
\b\w+@\w+\.\w+\b | Simple email | user@example.com |
(\d{2})/(\d{2})/(\d{4}) | Date DD/MM/YYYY with groups | 25/12/2024 |
(?<=@)\w+ | Lookbehind — word after @ | gmail (from user@gmail) |
Pro Tips
Use Non-Greedy Matching
Add ? after quantifiers (*?, +?, {n,m}?) to match as few characters as possible instead of as many.
Named Capture Groups
Use (?<name>...) to name your groups. In replace mode, reference them with $<name> for clearer substitutions.
Lookahead & Lookbehind
(?=...) lookahead and (?<=...) lookbehind match positions without consuming characters. Great for validating context.
Escape Special Characters
Characters like . * + ? ^ $ { } [ ] ( ) | \ have special meaning. Prefix with \ to match them literally.
Frequently Asked Questions
What regex flavor does this tool use?
This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript specification. It supports all standard flags including g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode), and y (sticky).
What are capture groups in regex?
Capture groups are created with parentheses () in a regex pattern. They let you extract specific parts of a match. For example, in the pattern (\d{4})-(\d{2})-(\d{2}), each set of parentheses captures a group: year, month, and day from a date string like 2024-01-15.
What does the g flag do?
The g (global) flag makes the regex find ALL matches in the string, not just the first one. Without g, the regex stops after the first match. With g, it continues searching through the entire string.
How does Find & Replace work?
In Replace mode, you can use $1, $2, etc. to reference captured groups in your replacement string. For example, matching (\w+)@(\w+) and replacing with $2/$1 would swap the parts around the @ symbol.
Is my data processed on a server?
No. All regex testing happens entirely in your browser using JavaScript. No data is sent to any server. Your patterns and test strings remain completely private.