Tools
Regex Tester
The regex tester lets you write a regular expression and test it against sample text in real time. Matches are highlighted inline, capture groups are listed with their indices and values, and any regex syntax errors are reported immediately. It supports all JavaScript regex flags including global, case-insensitive, multiline, dotAll, and unicode, making it a reliable tool for developing and debugging patterns before embedding them in code.
What is the Regex Tester?
The regex tester is an interactive tool for writing, testing, and understanding regular expressions. You enter a pattern and test text, and the tool instantly highlights all matches within the text and lists every capture group with its name (for named groups) and matched value. Syntax errors in the pattern are caught and reported before you even run the test. This feedback loop dramatically accelerates the process of developing correct patterns compared to writing regex directly in source code and running the full program to check results.
How does it work?
Enter your regex pattern in the pattern field, select the flags you want to apply, and paste or type your test text. The tool constructs a JavaScript RegExp object from your input and runs it against the test text using either matchAll (for global patterns) or exec. Each match is highlighted in the text with a distinct color. Below the text, a structured table shows each match, its position, and the values of all capture groups. Named capture groups are shown with their group name.
Typical Use Cases
- Developing a validation pattern for email addresses or phone numbers
- Testing a log parsing pattern against a sample log file
- Debugging a search-and-replace pattern before running it in production
- Learning regex by interactively seeing which parts of text a pattern matches
Step-by-step Guide
- Step 1: Enter your regular expression in the pattern field.
- Step 2: Select the desired flags (g, i, m, s, u).
- Step 3: Type or paste your test text into the text area.
- Step 4: Review the highlighted matches and the capture group table.
Example
Input
Pattern: (\d{4})-(\d{2})-(\d{2}) | Text: 'Date: 2024-03-15'
Output
Match: '2024-03-15', Group 1: '2024', Group 2: '03', Group 3: '15'
Tips & Notes
- Always use the global flag (g) when you want all matches, not just the first one.
- Enable the dotAll flag (s) if your pattern needs . to match newline characters.
- Test your pattern with edge cases: empty strings, very long input, and input with special characters.
Frequently Asked Questions
Why does my pattern work in the tester but not in my code?
Common causes include forgetting to escape backslashes in string literals (use \\d in a string, not \d), using flags that are not supported in the target environment, or subtle differences between JavaScript and server-side regex flavors.
What are named capture groups?
Named capture groups use the syntax (?<name>...) and assign a label to a capturing group. They make the regex more readable and allow you to access the match by name (match.groups.name) instead of by index.
Regex Tester
Test regular expressions in real time — with match highlighting, group display, replace function, and example patterns.
Open Tool