🔍 Regex Tester

Test and debug regular expressions with real-time pattern matching and highlighting. Perfect for developers validating input patterns, extracting data, and testing complex regex patterns.

📊 Highlighted Matches:
Enter text and regex pattern, then click "Test Regex" to see highlighted matches...
💡 How to use:
  • Enter sample text you want to search in the textarea
  • Enter your regex pattern in the pattern field
  • Optionally add flags (g=global, i=ignore case, m=multiline, s=dotall)
  • Click "Test Regex" to see highlighted matches
  • Matches will be highlighted in yellow
  • Error messages will display if the regex is invalid

📝 Common Regex Patterns:

Pattern Description Example
\d+ One or more digits 123, 4567
[a-z]+ One or more lowercase letters hello, world
[A-Z]+ One or more uppercase letters HELLO, WORLD
[a-zA-Z0-9]+ Alphanumeric characters abc123, XYZ789
\w+ Word characters (letters, digits, underscore) hello_world, test123
\s+ Whitespace characters spaces, tabs, newlines
[a-z]+@[a-z]+\.[a-z]+ Simple email pattern user@example.com
^https?:\/\/ HTTP/HTTPS URLs https://example.com
\b\w{3,}\b Words with 3+ characters hello, world
^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ IP Address pattern 192.168.1.1
📚 Regex Flags:
  • g - Global: Find all matches (not just first)
  • i - Ignore Case: Case-insensitive matching
  • m - Multiline: ^ and $ match line breaks
  • s - Dotall: . matches newlines
  • gi - Combine flags: Global + Ignore Case
💡 Tip: Always use the 'g' flag to find all matches in your text. Without it, only the first match is found.

What the JavaScript flavour changes

Your pattern goes straight into new RegExp(pattern, flags), so type the body alone - no surrounding slashes - and put the flag letters in the second box:

type this:   \d{3}-\d{4}          not this:   /\d{3}-\d{4}/g
flags box:   gi                   (letters only, no slashes)

This engine is not PCRE. \d, \w and \b are ASCII-only, so \w+ stops dead at the accent in café - reach for \p{L}+ with the u flag when your text is not plain English. Lookahead (?=...), lookbehind (?<=...) and named groups (?<year>\d{4}) all work; atomic groups, possessive quantifiers, recursion and the verbose x flag do not exist in JavaScript at all.

Every flag JavaScript accepts

gCarry on past the first match
iCase-insensitive, ranges like [a-z] included
m^ and $ match at every line break, not just the ends
s. also matches a newline
uUnicode mode: enables \p{...}, treats emoji as single characters
vu plus set arithmetic inside character classes
ySticky: the match must begin exactly where the last one ended
dRecords the start and end index of each capture group
Any other letter throws "Invalid flags". Avoid patterns that can match nothing - \d* or a bare ^ - with the g flag: a zero-length match never advances, and the search will spin until you reload the page.

Frequently asked questions

Why does my pattern find nothing when it works in my editor?

Usually the delimiters. /cat/i pasted into the pattern box looks for a literal slash, a c, an a, a t and another slash. Enter cat and put i in the flags box.

Why are my capture groups not shown?

The highlighter marks the whole match only. Total Matches counts every hit and Unique Matches counts the distinct strings among them; to inspect group contents, run the same pattern in your browser console.

How do I match a whole word rather than part of one?

Wrap it in word boundaries: \bcat\b finds cat but not concatenate. Remember \b is defined against ASCII word characters, so it lands in odd places inside accented or non-Latin words.