This regex tester runs a regular expression against your sample text as you type and highlights every match, using your browser's JavaScript RegExp engine, so results match what the same pattern gives in JavaScript code. Type your own pattern or start from one of eight quick patterns, including email addresses, URLs, phone numbers, IP addresses and dates. Each match is listed with its position and captured groups.
How to use the regex tester
- Enter your pattern in the pattern field, between the two slashes, without typing the slashes yourself.
- Pick flags from the menu:
g(global) finds every match,iignores case andm(multiline) makes ^ and $ match at the start and end of each line. The menu offers g, gi, gim, i and m, so flags such as s and u are not available. - Paste your test string into the text area below.
- Matches are highlighted as you type, and the counter shows how many were found. Without g, only the first match is shown.
- Review Match Details for each match's text, index and captured groups. Groups that did not take part in a match are left out, so the numbers in that list can differ from the group numbers in your pattern.
Quick patterns and what they really match
Each quick pattern button fills in the regex tester's pattern field and keeps your current flags. They are starting points, and a few are looser than their names suggest:
- IP Address checks the dotted shape only, so 999.999.999.999 matches as well as 10.0.0.1.
- Date expects US month, day, year order, such as 11/06/2026 or 11-06-2026, with years from 1900 to 2099. An ISO date like 2026-11-06 does not match.
- Hex Color matches #fff and #1F5C99 and captures the digits after the #.
- Numbers only (
\d+) and Alphanumeric ([a-zA-Z0-9]+) match runs of ASCII characters, so an accented letter such as é splits a word into two matches.
Worked example: pulling dates out of text
Pattern (\d{4})-(\d{2})-(\d{2}) with the g flag, against this test string:
Shipped 2026-11-06, delivered 2026-11-09.
The counter shows 2, and Match Details lists:
#1 2026-11-06 index 8 Groups: [1] 2026 [2] 11 [3] 06
#2 2026-11-09 index 30 Groups: [1] 2026 [2] 11 [3] 09
Switch the flags to i and only the first match remains. For a log file, ^ERROR with gim finds every line that starts with ERROR (or error, since i is part of that option). On a four-line log with two such lines it finds both. With g alone it finds none, because ^ then means the start of the whole text and the first line begins with INFO.
Regex tester for JavaScript, compared with Python, Java and C#
Character classes, quantifiers, anchors, groups, alternation and lookahead work much the same in every major engine, so most patterns carry over. These are the differences that most often catch people out:
- Named groups are written
(?<year>\d{4})in JavaScript, Java and .NET, while Python's re module documents(?P<year>\d{4}). This tester accepts the JavaScript form and lists named groups by number. - Python's re module only allows fixed-width lookbehind, so
(?<=\$)\d+works there but(?<=\$\s*)\d+does not. JavaScript accepts both. - In Java and C# string literals every backslash is doubled, so
\d+is written"\\d+". Python raw strings (r"\d+") and C# verbatim strings (@"\d+") avoid that. Here you type single backslashes. - Java's possessive quantifiers, such as
a++, don't exist in JavaScript, and the tester reports them as an invalid pattern.
Tips to test regex online
- You don't need to escape a forward slash, because the field goes straight to
new RegExp(), soa/bworks as typed. Do escape a literal dot as\., or it matches any character. - Anchor validation patterns with ^ and $. Without them,
\d{5}also matches inside 123456. - Paste samples that should fail as well as ones that should pass. A regular expression tester only reports on the text in front of it, so include edge cases such as empty lines and trailing spaces.
- A pattern that can match an empty string, like
a*, still finishes: the tester steps past zero-length matches.
Some jobs need more than a regex tester. For phone lists from the Gulf states, India or Pakistan, the phone number formatter already applies each country's rules. To compare two versions of a text after a find-and-replace, paste both into the diff checker. Cron is another compact pattern syntax that trips people up, and the guide to cron every 5 minutes explains its five fields. More tools for code are in the developer tools section.