Developer Tools

Regex Tester

Regex tester for JavaScript regular expressions: highlights every match as you type and lists each match's index and captured groups.

⚙️ Pattern
/ /
📊 Results
0 matches found
Enter a pattern and test string above...

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

  1. Enter your pattern in the pattern field, between the two slashes, without typing the slashes yourself.
  2. Pick flags from the menu: g (global) finds every match, i ignores case and m (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.
  3. Paste your test string into the text area below.
  4. Matches are highlighted as you type, and the counter shows how many were found. Without g, only the first match is shown.
  5. 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(), so a/b works 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.

Frequently Asked Questions

What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Code uses regexes to check that input has the right format, to pull parts out of text and to find and replace.
Which regex flavor does this regex tester use?
JavaScript's, through the browser's RegExp object. Basic syntax such as character classes, quantifiers, groups and alternation works much the same in most languages, but advanced features and some escapes differ between engines, so test a pattern in the language you will use it in. Unicode property escapes such as \p{L} need the u flag, which this tester does not offer.
What does the global flag do?
The global flag (g) tells the regex engine to find all matches in the input string. Without it the engine stops after the first match, and this tester lists only that one.
Can I use this to validate email addresses or phone numbers?
Yes. The Email and Phone quick patterns are a starting point. The email pattern checks the usual name@domain.tld shape and does not cover every address the email standards allow, and the phone pattern expects North American numbers such as (555) 123-4567. To test a list, put one example per line, add ^ at the start and $ at the end of the pattern and choose a flag set with m, so each line has to match as a whole.
Why do I get an Invalid pattern error?
The browser could not compile the pattern, and the text after Invalid pattern says why. In Chrome an unclosed bracket gives Unterminated group, and a quantifier with nothing before it, such as a lone *, gives Nothing to repeat. Escape literal brackets, dots, stars and plus signs with a backslash.
Does the regex tester send my text anywhere?
No. The pattern and the test string are matched by JavaScript running in this page, and nothing is sent to a server. You can paste log lines or real customer data to test against, and it stays on your device.