Text Tools
Regex Tester
See matches and line-by-line results before using a pattern in an application.
Understand the format
How Regex Tester works
A pattern is only as good as the examples it has been tried against, including the ones that must fail. This tester shows both the matches found and a pass or fail verdict for each line.
Two views of the same pattern
The Matches list runs the expression globally across the whole sample and shows every substring it found, which is the right view when you are extracting data from logs or free text. The Line checks list runs the pattern once per line and reports whether that line matched, which is the right view when the pattern is a field validator.
The distinction matters because an unanchored pattern can produce a match on almost every line while still failing as a validator. Reading both views together is what exposes that: many matches but a line you expected to fail marked as matched means the pattern needs anchors.
Flags change the meaning, not just the speed
The g flag finds every match rather than stopping at the first. The i flag ignores case. The m flag makes ^ and $ match at each line boundary instead of only at the start and end of the whole input, which is exactly what you want when testing a multi-line sample. The s flag lets a dot match newlines, and u enables Unicode-aware matching including property escapes.
Because m changes what anchors mean, a pattern that appears to work on a multi-line sample can behave completely differently against a single value in production. Always test with the same flags the application will use.
Step by step
How to use Regex Tester
- Enter the pattern without surrounding slashes, then the flags you intend to use in your application.
- Paste sample text with one candidate value per line, including values that must be rejected.
- Read the Matches list to see what the pattern extracts, and the Line checks list for a per-line verdict.
- Add a new line to the sample every time production reveals a case you had not considered.
Patterns and sample text are evaluated by the browser regex engine in the page, so log excerpts used as samples never leave your machine.
Troubleshooting
Common mistakes and how to fix them
- A pattern behaves differently in application code than in a tester.
- Check the flags and the escaping. A pattern written in a string literal needs its backslashes doubled, so \d becomes \\d.
- Nested quantifiers such as (a+)+ against a long non-matching string.
- This is catastrophic backtracking, the basis of regular-expression denial of service. Rewrite to avoid nesting, or apply a length limit before matching.
- Reusing a global regex object and getting alternating results.
- A regex with the g flag keeps a lastIndex between calls to test and exec. Create a fresh instance, or reset lastIndex to zero.