Regex Tester

Write a regular expression and test it against sample text in real time. Highlights all matches, shows capture groups. Pairs with the URL Encoder for routing patterns and the JSON Formatter for testing against structured data when building routing patterns, and displays match count. Supports all JavaScript regex flags: g, i, m, s, u.

Developer Tools

Regular Expression
/ /
Test String
📄 Drop a .txt file here, or
Highlighted Matches

What This Tool Does

Tests regular expressions against sample text in your browser in real time, highlighting all matches, groups, and capturing groups as you type. Supports JavaScript, PCRE, and Python regex syntax.

Who This Is For

  • Developers writing input validation patterns who need to test against real data before deployment
  • Data engineers cleaning messy datasets with regex-based transformations
  • Security engineers writing log analysis patterns to detect anomalies
  • Anyone learning regular expressions who wants immediate visual feedback on pattern matches

Example: Input: The regex \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b with the i flag, tested against a paragraph of text → Output: All email addresses in the text highlighted, with each capture group labeled and the full match list shown below

How to Test a Regular Expression

  1. Enter your regular expression in the Regex field (without delimiters — just the pattern itself).
  2. Select the flags you need: g (global — find all matches), i (case-insensitive), m (multiline), s (dot matches newline).
  3. Paste your test string into the input area.
  4. Matches are highlighted in real time as you type.

The tool shows capture groups separately. Regex patterns are used in JSON Schema validation and cron expressions — both tools are one click away. The tool also shows capture groups to verify that your groups extract the right data.

Regular Expression Syntax Quick Reference

PatternMeaningExample Match
.Any character except newlinea.c → "abc", "a1c", "a c"
\dDigit (0–9)\d{4} → "2026"
\wWord character (letter, digit, _)\w+ → "hello_world"
\sWhitespace\s+ → spaces, tabs, newlines
^Start of string/line^Hello → matches if string starts with "Hello"
$End of string/lineend$ → matches if string ends with "end"
*Zero or morego* → "g", "go", "goo", "gooo"
+One or morego+ → "go", "goo" (not "g")
?Zero or one (optional)colou?r → "color" or "colour"
{n,m}Between n and m times\d{3,4} → 3 or 4 digits
[abc]Character class[aeiou] → any vowel
[^abc]Negated class[^0-9] → any non-digit
(abc)Capture group(\d{4})-\d{2} captures year
(?:abc)Non-capturing groupGroups without capture overhead
(?<name>)Named capture group(?<year>\d{4})
a|bAlternation (or)cat|dog → "cat" or "dog"

Common Regex Patterns

Text Processing Workflow

Regex testing is part of a data validation and transformation workflow:

Related Tools

Related Guides

Frequently Asked Questions

What are regex flags and which should I use?
Flags modify how a pattern matches. The most common: g (global — find all matches, not just the first), i (case-insensitive), m (multiline — ^ and $ match line boundaries, not just string boundaries), and s (dotall — . matches newlines). Combine them: gi finds all matches case-insensitively.
What is the difference between greedy and lazy matching?
By default, quantifiers like * and + are greedy — they match as much as possible. Adding ? makes them lazy — they match as little as possible. Example: <.*> on <a>test</a> matches the entire string. <.*?> matches only <a>.
How do I match a literal dot or other special character?
Escape it with a backslash: \. matches a literal dot. Other characters that need escaping: \*, \+, \?, \(, \), \[, \{, \^, \$, \|, \\.
What is a capture group?
Parentheses create a capture group: (\d{4}). When a match is found, the text matched by each group is available separately. Named groups ((?<year>\d{4})) let you access captures by name instead of index.
Why does my regex work in regex101 but not in my code?
Regex syntax has minor differences between engines (JavaScript, Python, Java, .NET, PCRE). This tester uses the JavaScript engine. Differences include: Python uses (?P<name>) for named groups, while JavaScript uses (?<name>). Also check string escaping — in code, backslashes must be doubled in regular string literals.
What causes catastrophic backtracking?
Certain patterns like (a+)+ on a non-matching string cause exponential backtracking — the engine tries an enormous number of combinations before failing. This can hang your application. Avoid nested quantifiers on overlapping patterns. Test with strings that do NOT match to check performance.