Regex Tester with Visual Highlighting and Capture Groups
Test a JavaScript regular expression against text and inspect matches, groups, indices, and highlighting.
- JavaScript flags d, g, i, m, s, u, v, and y
- Visual match highlighting
- Capture group detection
- Syntax error explanation
- Copy pattern
Test patterns, flags, and captures with immediate feedback
Build a regular expression, enter test text, and review matches, captured groups, and visual highlighting.
Enter a valid regular expression to test.
Enter test text to run the expression.
Correct the expression or flags to run the test.
Test the regex, review matches, and refine the pattern
- 1. Write the regex pattern without delimiter slashes.
- 2. Enter the flags you need, such as g, i, m, or s.
- 3. Paste test text and watch the highlighting update.
- 4. Review matches, indices, and groups before copying the result.
Keep regexes readable and maintainable
- Test real inputs and edge cases before taking a regex to production.
- Use groups only when they have a semantic purpose to reduce noise.
- Document complex expressions with examples and usage context.
- Prefer readable patterns and review the impact of global and multiline flags.
Investigate patterns before putting them in code
The tester helps developers, QA, students, and technical support observe how a JavaScript regular expression behaves against concrete text.
- Adjust a pattern while checking each match value and index.
- Review capture groups before turning a match into data.
- Compare flags and test cases that represent real input.
How to test a regular expression
- 1. Enter only the pattern, without / / delimiters.
- 2. Enter supported flags without duplicates, such as gi or m.
- 3. Paste text containing positive and negative cases.
- 4. Review matches, indices, groups, and highlighting before copying the report.
The tester uses JavaScript's RegExp dialect
The tool creates a RegExp from the pattern and flags. To collect multiple matches, it adds g to the compiled flags when g was not supplied.
Flags
The validator accepts d, g, i, m, s, u, v, and y without duplicates.
g scans for multiple matches, i ignores case, and m changes line anchors; the others affect specific RegExp capabilities.
Matches and indices
Each match shows the text found and its starting index in the test string.
Indices are JavaScript string positions, not a word count.
Groups and highlighting
Capture groups are shown for each match and matched text receives visual highlighting.
Highlighting visualizes matches; it does not mean every possible input was tested.
Finding order codes
Use the pattern below, flag g, and the indicated text. The result should find two codes.
\b[A-Z]{2}\d{3}\bOrder AB123 and CD999; reference XX12.
AB123 (index 6)\nCD999 (index 16)
XX12 does not match because it has only two digits; that demonstrates the exact limit defined by the pattern.
One positive test is not the whole review
A positive test does not prove that an expression covers every case or make an input safe.
- The tester uses JavaScript RegExp; patterns from other implementations can have different rules or features.
- A few examples do not cover variations, empty text, Unicode, multiple lines, or malformed cases.
- The tool does not guarantee performance, freedom from costly backtracking, business validation, or safety of text that will be processed.
Test cases that can fail
Include positive, negative, boundary, and unexpected inputs. Then review how the expression is used in the real context, especially when text comes from users.
Frequently asked questions
Should I include / / around the pattern?
No. Enter only the pattern, such as \d{3}-\d{2}, and use the separate field for flags.
Which flags does the tool accept?
The validator accepts d, g, i, m, s, u, v, and y without repeated characters. If g is absent, it is added internally to collect matches.
What does the displayed index mean?
It is the starting position of the match in the test string, counted according to JavaScript string indices.
Does a found match prove the regex is correct?
No. It only shows that this text produced that match. Also test negative cases, boundaries, and variations of the expected format.
Does a tested regex make input safe?
No. Testing does not replace business validation, normalization, authorization, size controls, or performance and security review.