Compyrix logo

Regex Tester

Test regular expressions with live highlighting.

The quick brown fox jumps over the lazy dog. Email: test@example.com, hello@world.org Phone: 123-456-7890, (555) 123-4567

Regular expressions (regex or regexp) are powerful patterns for matching, searching, extracting, and validating text. They are used in every programming language, text editor, and command-line tool, but their dense syntax is notoriously tricky to get right. Our free Regex Tester lets you experiment with JavaScript regex live, with instant highlighting and match details.

Enter your regex pattern in the pattern box (without surrounding / slashes — though they will be stripped if you include them), toggle flags (g, i, m, s, u, y), and type or paste your test text. Matching substrings are highlighted in the text panel as you type, and the match list below shows every match with its index position, captured groups, and full match text.

The flags: g = global (find all matches, not just the first), i = case insensitive, m = multiline (^ and $ match line boundaries), s = dotAll (the . metacharacter also matches newlines), u = Unicode (enable full Unicode support, including for p{} property escapes), y = sticky (match only from lastIndex).

We also include a quick reference card of common regex patterns directly below the tool: anchors, character classes, quantifiers, groups, lookaheads, and ready-to-use examples like email, URL, phone, and IPv4 patterns. This makes the tester useful both as a playground and as a learning reference.

Frequently Asked Questions

Why does my pattern work in the tester but not in my code?
The most common causes are: forgetting the g flag when iterating matches (matchAll and replaceAll require it), string escaping differences (in code, \\ is one backslash vs. \ in the tester input), different regex dialects (our tool uses JavaScript regex — .NET, Python, and PCRE have different features), and missing the m flag when using ^ or $ to match lines.
What do the captured groups mean?
Parentheses (...) in a regex create capture groups. Group 0 is always the entire match. Groups 1, 2, 3, etc. correspond to each pair of parentheses in the order they appear (counting left parens). Use non-capturing groups (?:...) if you need grouping for alternation but do not want to extract the value. Named groups (?<name>...) are also supported in the JavaScript dialect.
Can a regex pattern be too slow?
Yes! Poorly written regexes (especially nested quantifiers like (a+)+b) can exhibit catastrophic backtracking, taking exponential time on long strings and even crashing the page. Our tester has no timeout protection, so if your browser tab freezes, close it and simplify the pattern or split it into smaller steps.
How do I validate an email address with regex?
Email validation is surprisingly complex and full RFC 5322 compliance is extremely long. For practical use, a pattern like /^[^s@]+@[^s@]+.[^s@]+$/ checks the essentials (one @, a domain with at least one dot) and rejects clearly invalid input. For strict validation, use a dedicated library rather than a handwritten regex.

Related Tools