Tester

Regex Tester

Iterate on regular expressions with real-time matches, explanations, and sample datasets.

Flags

Input Character Count: 0

Error:

Regex Tester

Test JavaScript regular expressions against your own text. Matches are highlighted as you type, the number of matches is shown, and each match is listed with its position, capture groups and named groups. The flags g, i, m, s, u and y are turned on with checkboxes, and a list of 30 common patterns, from email addresses to IPv4, gives you a starting point.

How to use

  1. Optionally pick a ready-made pattern from Common Patterns, such as Email address, URL, IPv4 address or Date (YYYY-MM-DD).
  2. Type or edit the pattern in the Regex Pattern field, without surrounding slashes, for example \d{3}-\d{4}.
  3. Tick the flags you need: Global search (g), Case insensitive (i), Multiline (m), Dot matches newline (s), Unicode (u) or Sticky (y).
  4. Enter the text to test in the Test Text box.
  5. Check the Highlight and Match Details: each match's text, its start and end position, $1, $2 … capture groups and named groups. A syntax error in the pattern is shown above the field.

Frequently asked questions

Which regex flavor does it use?
JavaScript's RegExp, as run by your browser, so results match what your JavaScript or TypeScript code will do. Lookahead, lookbehind, named groups (?<name>…) and Unicode property escapes such as \p{L} (with the u flag) work in current browsers. PCRE-only features such as possessive quantifiers, atomic groups and recursion are not available.
Should I type the slashes, like /abc/g?
No. Enter only the pattern and set flags with the checkboxes. Slashes typed in the field are treated as part of the pattern.
What do the flags do?
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 . match line breaks, u enables full Unicode handling, and y (sticky) only matches at the exact position where the previous match ended.
Why is only one match listed?
Without the g flag, a JavaScript regex stops at the first match, so the count and Match Details show only that one. The Highlight still marks every place the pattern matches, so you can see what g would find.
Can I test capturing groups?
Yes. Numbered groups are listed as $1, $2 and so on, and named groups by their names. A group that did not take part in the match is shown as (empty).
How reliable are the Common Patterns?
They are simple format checks to start from. For example, the date pattern accepts 2024-13-45, the IPv6 pattern only accepts the full eight-group form, and the email pattern does not cover every valid address. Adjust them to your data.
How are positions counted?
From 0, the way JavaScript indexes strings. The position shows the index of the first and last character of the match. Emoji and other characters beyond U+FFFF count as two.
Can I replace matches too?
This page only finds matches. To replace them, use the Find & Replace tool, which accepts the same regular expressions and $1 or $<name> references in the replacement.
Is my text sent anywhere?
No. Matching runs in your browser. The pattern, flags and test text are kept in the page URL, so you can bookmark a test or share it with a teammate.