Regex Tester
Test and debug regular expressions
Flags in use: /g
0 matches found
Reading results never uses a trial use. Copying, saving or printing uses 1 per visit.
About Regex Tester
Tests a regular expression against sample text in real time, highlighting matches directly within the text as you build and refine the pattern — rather than leaving you to figure out where a match landed from a raw list of index numbers.
Enter your regular expression and some test text. Matches are highlighted directly in the text below as you type, with a plain-language explanation if the pattern is invalid, and each match's captured groups (the parts inside parentheses) shown separately when your pattern uses them.
Build complex patterns incrementally — start with a simple pattern that matches the basic case, confirm it works, then add complexity piece by piece rather than trying to write the whole expression at once. If a pattern isn't matching what you expect, check the highlighted text first — seeing exactly what it caught (and didn't) is usually faster than staring at the pattern alone.
Watch: Regex Tester in Action
- What's the best way to build a complex regular expression?
- Build it incrementally — start with a simple pattern that matches the basic case, confirm it works, then add complexity piece by piece rather than trying to write the whole expression at once.
- Which regular expression syntax does this tester use?
- The JavaScript engine of the browser you are using. Features like lookahead, lookbehind in current browsers, named groups and the u flag follow JavaScript rules. Patterns written for Python, PCRE or Java may need small changes, so confirm them in their own environment before relying on them.
- Why do I only see one match when the text has several?
- The Global (g) switch is probably off. With it off the tool stops after the first match on purpose. Turn Global on and the count, shading and list will include every match in the text, up to 1000.
- What does the message about 1.5 seconds mean?
- The pattern ran too long and was cancelled so your tab would not lock up. This usually points to catastrophic backtracking, where nested or overlapping repeats like (a+)+ have to try a huge number of paths. Make the repeated parts less ambiguous and try again.
- The count says matches were found but nothing is shaded. Why?
- Your pattern can match an empty string, for example a* on text without a. Those matches have no characters, so there is nothing to shade, yet they are counted and listed with their index. Require at least one character, such as a+, to see visible highlights.
- What does the Unicode (u) switch change?
- It makes the engine read the text as full Unicode characters instead of 16-bit units, so an emoji counts as one character and property escapes like p{L} become available. It also makes the engine stricter, so a pattern with an unneeded escape can become an error.
How to use Regex Tester
Type your pattern into the Regular Expression box, without surrounding slashes, and paste the text you want to search into Test String. Nothing is evaluated until both boxes have content. Five switches set the flags: Global (g) and Ignore case (i) start on, while Multiline (m), Dot matches newline (s) and Unicode (u) start off.
Matches are shaded in the Highlighted Text panel. The box beneath states the match count and lists each hit with its zero-based index and any capture groups, numbered in order, plus named groups by name. The page re-runs roughly a quarter of a second after you stop typing. Switch Global off if you only want the first match in the text.
When to use it
Reach for it when you are drafting a pattern for form validation, a log search, an editor's find-and-replace or a scraping script and want to see what it really catches before pasting it into code. It also helps when a pattern that works on one sample misbehaves on another: paste several lines and watch which ones light up and which capture groups fill in.
When not to use it
Do not trust it for patterns destined for another language. It uses the JavaScript regular expression engine built into your browser, so lookbehind support, possessive quantifiers, inline flags and named group syntax can differ in Python, PCRE or Java. Test those in the target runtime. It also has no replace mode, so use your editor's replace preview for substitutions.
Tips for best results
When a pattern seems to match nothing, check the switches before the pattern: without Multiline, ^ and $ anchor only to the start and end of the whole text, and without Dot matches newline, a dot stops at every line break. Named groups such as (?<year>[0-9]{4}) give readable labels in the result list. Grow the pattern one piece at a time and watch the shading change.
Limitations
Each run is given 1.5 seconds. A pattern with nested repetition, such as (a+)+ against a long string of a's, is stopped and you see a warning instead of results. At most 1000 matches are collected, and the counter then shows 1000+. Only the first 20 matches are listed in detail, although every collected match is shaded in the text. The tool does not explain what a pattern means.
Privacy
The pattern and sample text are handed to a background worker thread inside your browser tab, which runs the match and returns the positions to the page. Neither is posted to a server for matching, and nothing is fetched while you type. The tool does not store your pattern or text, so closing the tab discards both.
More from Security & Developer: