Regex Tester
Test and debug your regular expressions with real-time match highlighting and replace options.
Invalid Regular Expression
| Index | Match Range | Content | Groups |
|---|---|---|---|
| No matches to show | |||
What is a Regular Expression (Regex)?
A Regular Expression (Regex) is a sequence of characters that forms a search pattern. It is used in programming, text editors, and databases to perform advanced pattern matching, search-and-replace, and data validation operations. Regex patterns can range from simple word matches to complex expressions that validate emails, phone numbers, or extract nested data structures.
How it Works
Our Regex Tester uses the JavaScript regular expression engine built into your browser. You input a regular expression pattern, select your desired flags (Global g, Case-Insensitive i, Multiline m, or DotAll s), and type in the test string. The tester automatically highlights all matching strings, captures named and numbered groups, and reports match positions in real-time. If you enable the replacement option, the tool performs a replacement operation and previews the modified text instantly. It catches regex syntax errors safely, warning you of invalid expressions without crashing.
Understanding Regex Flags
- g (Global): Find all matches rather than stopping after the first match.
- i (IgnoreCase): Ignore case distinctions (e.g., matching 'a' and 'A').
- m (Multiline): Treat beginning and end characters (^ and $) as working across multiple lines.
- s (DotAll): Allow the dot (.) special character to match newline characters.
Frequently Asked Questions
This tester uses the native JavaScript RegExp engine built into your web browser. Patterns will match the RegExp behavior of modern JavaScript.
We support the four most common flags: Global (g) to find all matches, Case-Insensitive (i), Multiline (m) to match ^ and $ across lines, and DotAll (s) to allow dot to match newline characters.
When a pattern matches, the match list below displays details of each match, including its index, length, and a sub-list of all captured groups (both numbered groups and named groups).
Yes, you can toggle the "Enable Replace" checkbox, enter your replacement string (supports $1, $2 group backreferences), and see the substituted result updated in real-time.
The tester catches the regular expression parser errors and displays a friendly error banner explaining the syntax mistake, preventing the application from crashing.