Regex Tester

Your data never leaves your browser

Test regular expressions with real-time match highlighting. See capture groups, named groups, and match positions.

//
Flags:
//g
Test String
Enter a pattern and test string above
Ctrl+Shift+CCopy matchesCtrl+KClearResults update as you type

Share this tool

Found it useful? Help a fellow developer discover it.

https://developertoolkit.dev/tools/regex-tester

How to use the Regex Tester

  1. Type your pattern in the /pattern/ field. Matches update instantly as you type.
  2. Toggle flags using the letter buttons next to the pattern: g (global), i (case-insensitive), m (multiline), s (dot-all), u (unicode).
  3. Paste your test string in the editor below the pattern.
  4. The Match Preview section highlights each match inline with distinct colors.
  5. The Matcheslist shows each match's value, position, length, and all capture groups (numbered and named).

JavaScript regex flags explained

FlagNameEffect
gGlobalFind all matches in the string, not just the first one. Without this flag, only the first match is returned.
iCase-insensitiveMake the pattern match regardless of letter case. /hello/i matches "Hello", "HELLO", "hElLo".
mMultiline^ and $ match the start and end of each line (not just the whole string). Essential when testing multi-line input.
sDot-allMakes . match any character including newlines (\n). Without this flag, . only matches non-newline characters.
uUnicodeEnable full Unicode matching. Required for patterns that use Unicode property escapes (\p{...}) or match astral plane characters (emoji, etc.).

Common regex patterns

Email address

/[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}/g

Matches common email addresses. Not RFC 5321 compliant but covers 99% of real-world emails.

IPv4 address

/\b(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g

Matches valid IPv4 addresses (0.0.0.0 – 255.255.255.255).

UUID v4

/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gi

Matches UUID v4 strings in standard hyphenated format.

ISO 8601 date

/\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])/g

Matches dates in YYYY-MM-DD format (e.g. 2024-01-15).

Hex color

/#(?:[0-9a-fA-F]{3}){1,2}\b/g

Matches 3 or 6-digit hex color codes (#fff or #ffffff).

JWT token

/[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g

Matches JWT tokens (three Base64URL segments separated by dots).

Frequently Asked Questions

How do I test a regex pattern online?

Type your pattern in the /pattern/ field and paste your test string in the editor below it. Matches are highlighted in real time as you type. Toggle flags (g, i, m, s, u) using the letter buttons next to the pattern field. The Matches list shows each match value, position, length, and all capture groups.

What is the difference between regex and glob patterns?

Regex (regular expressions) is a powerful pattern language for matching text based on characters, classes, quantifiers, and anchors. Glob patterns (used in file systems and shell commands) are simpler, using only * (any characters), ? (one character), and [...] (character sets). A regex like ^src/.*\.tsx$ is the glob equivalent of src/**/*.tsx. Globs cannot express groups, alternation, or lookaheads.

Why does my pattern with .* match the entire string?

.* is greedy, meaning it matches as many characters as possible. Use .*? for a non-greedy (lazy) match, which stops at the first opportunity. For example, <.*> matches the whole string "<b>text</b>", while <.*?> matches only "<b>".

What is the difference between ^ and $ in multiline mode?

Without the m flag, ^ matches the very start of the string and $ matches the very end. With the m flag, ^ matches the start of each line and $ matches the end of each line. This is essential when you want to match patterns at line boundaries in multi-line text.

How do I use named capture groups?

Use (?<name>...) syntax. For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) captures the parts of a date as named groups year, month, and day. This tool shows named group values in the match list alongside numbered groups.

What causes catastrophic backtracking?

Patterns like (a+)+ on long strings can cause exponential time complexity as the regex engine tries every possible way to match. Avoid nested quantifiers on overlapping character classes. If your test string is large and the page becomes unresponsive, this is the likely cause. This tester has a 10,000-match safety limit to prevent hangs.

Does this tester use JavaScript regex syntax?

Yes. It uses JavaScript's built-in RegExp engine running in your browser. Syntax and behavior may differ from PCRE (PHP, Python), POSIX (grep), or .NET regex. Most common patterns are compatible, but features like variable-length lookbehind assertions (supported in Python but not all JS engines) may behave differently.

How do I match a specific word but not as part of a longer word?

Use word boundary anchors: \b before and after the word. For example, \bcat\b matches "cat" in "the cat sat" but not in "caterpillar" or "concatenate". Without the anchors, cat would match the substring in all three. Add the g flag to find all occurrences in a string.

Related Tools