Regex Tester
Online Regular Expression Tester
Test your regular expressions in real time with instant match highlighting. Enter a regex pattern and a test string to see all matches highlighted as you type. This tool uses JavaScript's native RegExp engine, making it perfect for validating patterns before using them in your code.
What Are Regular Expressions?
Regular expressions (regex or regexp) are sequences of characters that define a search pattern. They are a powerful tool for text processing — used for validation (email, phone numbers), search and replace, data extraction, log parsing, and input sanitization. Nearly every programming language supports regular expressions, though syntax details vary slightly between implementations.
Regex originated from formal language theory in the 1950s and was first implemented in Unix text processing tools (ed, grep, sed) in the 1960s-70s. Today they're essential in web development, data engineering, system administration, and security.
How to Use This Regex Tester
Type your regular expression between the slashes. Add flags (g, i, m, s) after the closing slash. Paste or type your test string below. Matches are highlighted in yellow automatically as you type. The match details table shows each match with its position, captured groups, and captured text.
Regex Flags Reference
- g (global) — Find all matches, not just the first one. Essential for search-and-replace operations.
- i (case-insensitive) — Match regardless of uppercase or lowercase.
/hello/imatches "Hello", "HELLO", and "hello". - m (multiline) — Make
^and$match the start and end of each line, not just the start and end of the entire string. - s (dotall) — Make
.match newline characters too. Without this flag,.matches any character except\n.
Quick Reference — Common Patterns
.— Any character (except newline withoutsflag)\d— Digit [0-9].\Dmatches non-digits.\w— Word character [a-zA-Z0-9_].\Wmatches non-word characters.\s— Whitespace (space, tab, newline).\Smatches non-whitespace.*— Zero or more of the previous element+— One or more of the previous element?— Zero or one (optional){n,m}— Between n and m repetitions()— Capture group — extracts matched text(?:)— Non-capturing group — groups without extracting|— Alternation (OR) —cat|dogmatches either^/$— Start / End of string (or line withmflag)\b— Word boundary — matches the position between a word and non-word character
Common Regex Patterns
- Email:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL:
https?://[^\s]+ - IP Address:
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b - Phone (US):
\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} - Date (YYYY-MM-DD):
\d{4}-\d{2}-\d{2} - HTML Tag:
<[^>]+>
Frequently Asked Questions
Which regex flavor does this use?
This tool uses JavaScript's native RegExp engine (ECMAScript specification). It supports most common regex syntax including lookahead (?=), lookbehind (?<=), named groups (?<name>), and Unicode property escapes (\p{...}). Some features available in PCRE (Perl-compatible regex) like recursive patterns are not supported.
Is my data safe?
Yes. All matching runs entirely in your browser using JavaScript. Nothing is sent to any server. You can safely test patterns against sensitive data.
Why is my regex slow with certain patterns?
Some patterns cause "catastrophic backtracking" — exponential time complexity when the engine tries many possible paths. Common culprits include nested quantifiers like (a+)+ or overlapping alternatives. If your pattern is slow, try making quantifiers more specific or use atomic groups.
How do I match a literal special character?
Escape special regex characters with a backslash: \. matches a literal period, \* matches a literal asterisk. The characters that need escaping are: . * + ? ^ $ { } [ ] ( ) | \
What is a capture group?
Parentheses () create capture groups that extract portions of the matched text. For example, (\d{4})-(\d{2})-(\d{2}) applied to "2026-04-02" captures "2026", "04", and "02" as separate groups. Use $1, $2, etc. to reference them in replacements.