Skip to main content

Regex Tester

Test regular expressions against text with real-time match highlighting.

Built and tested by Muhammad Irfan Liaqat · Updated

//g

Regex Tester: key facts

  • Tests JavaScript regular expressions against your text with live match highlighting
  • Lists each match with its position and the value of any named capture groups
  • Supports the g, i, m, s, u, v and y flags
  • Matching only: there is no find-and-replace

How the regex tester works

Type a regular expression and a test string, and every match is highlighted as you type, with a list of the matches and any named capture groups. The tester uses your browser's JavaScript RegExp engine, so a pattern behaves here exactly as it will in JavaScript or Node.js code.

Seven flags can be switched on: g finds every match instead of only the first, i ignores case, m makes ^ and $ match at the start and end of each line, s lets the dot match line breaks, u turns on full Unicode matching, v is a stricter Unicode mode that adds set operations inside character classes, and y (sticky) only matches at the current position. Hover over a flag to see what it does. Other languages use slightly different regex flavours; Python, PHP and Java support most of the same syntax but differ in details such as the syntax for named groups, so test a complex pattern in its target language too.

How to test a regular expression

  1. 1Enter your regular expression in the pattern box
  2. 2Switch on the flags you need, such as g, i or m
  3. 3Type or paste the text to test against
  4. 4Check the highlighted matches and the match list

Frequently Asked Questions

Which regex flavour does this use?
JavaScript's built-in RegExp engine, which supports character classes, quantifiers, lookahead and lookbehind, named groups and Unicode property escapes such as \p{L} for any letter. Property escapes only work with the u or v flag switched on; without it, \p{L} is read as the plain text p{L}.
What do the regex flags do?
g (global) returns every match, i makes matching case-insensitive, m (multiline) lets ^ and $ match at each line, and s (dotAll) lets . match newline characters. u (unicode) treats emoji and other characters outside the basic range as one character and enables \p{...} escapes; v (unicodeSets) does the same and also allows set operations such as [\p{L}--[a-z]]. y (sticky) only matches at the position where the last match ended. u and v cannot be used together, so turning one on turns the other off.
How do I use named capture groups?
Write (?<name>pattern). For example, (?<year>\d{4})-(?<month>\d{2}) matches 2026-10 and labels the parts year and month.
What do \d, \w and \s mean?
\d matches a digit (0–9), \w matches a letter, digit or underscore, and \s matches whitespace such as a space, tab or line break. Capital versions (\D, \W, \S) match the opposite.
What is a simple regex for an email address?
^[^\s@]+@[^\s@]+\.[^\s@]+$ checks for text, an @, more text, a dot and an ending, with no spaces. It catches typing mistakes but not every invalid address, so confirm addresses by sending an email.
What regex matches a US phone number?
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$ matches 555-123-4567, (555) 123-4567, 555.123.4567 and 5551234567. Formats differ by country, so adjust the digit counts for other numbers.
Why does my regex work here but not in Python?
Python's re module is a different regex flavour. It writes named groups as (?P<name>...), sets flags through arguments such as re.IGNORECASE, and has no v flag. Most basic patterns, such as \d, \w and character classes, behave the same.
Does it support lookahead and lookbehind?
Yes. Lookahead (?=...) and (?!...) and lookbehind (?<=...) and (?<!...) all work in current versions of Chrome, Edge, Firefox and Safari.

Related Tools

Guides