Regex Tester
Test regular expression patterns in real-time. Supports matching, group extraction, and replacement.
Last updated:
How to Use
Expand how to useCollapse how to use
- 1
Enter your pattern
Type your regular expression pattern in the input field. Set flags (global, case-insensitive, etc.) as needed.
- 2
Enter test string
Enter the text you want to test against the pattern. Matches will be displayed in real-time.
- 3
Review and replace
Matched portions are highlighted. Enter a replacement string to preview the replacement result.
Regex Pattern
Test String
Match Results
Replace
About Regex Tester
Regex Tester lets you build, test, and debug regular expressions in real time using the JavaScript (ECMAScript) engine. As you type a pattern, every match in the test string is highlighted immediately and numbered so you can see exactly what the expression captures. Capture groups — both numbered and named — are listed with their extracted values, and a replacement field lets you preview substitution results using $1, $2, or $<name> references. Six flags are available: global (g), case-insensitive (i), multiline (m), dotAll (s), Unicode (u), and sticky (y). Execution time is displayed for every evaluation, helping you spot catastrophic backtracking (ReDoS) patterns before they reach production.
Key Features
- Real-time matching - See results instantly as you type
- Group extraction - View capture groups and named groups
- Replacement preview - Instantly preview replacement results with $1, $2 group references
- Flag settings - 6 flag options including global, case-insensitive, and multiline
- Execution time display - Monitor performance and detect ReDoS patterns
Common Use Cases
- Build and test regex patterns for form validation
- Debug regex for log parsing or data extraction
- Preview search-and-replace with regex in bulk text
- Validate email, URL, or phone number patterns
- Detect ReDoS vulnerabilities before deploying
Frequently Asked Questions
Which regex engine is used?
This tool uses the JavaScript (ECMAScript) regex engine built into your browser. It supports standard constructs including character classes, quantifiers, lookaheads, lookbehinds, and named capture groups. Language-specific extensions found in Perl (possessive quantifiers, atomic groups) or Python ((?P<name>) syntax) are not available.
What do the flags mean?
g (global) finds all matches instead of stopping at the first. i (case-insensitive) ignores letter case. m (multiline) makes ^ and $ match the start and end of each line. s (dotAll) allows . to match newline characters. u (Unicode) enables full Unicode matching and lets you use \p{} property escapes. y (sticky) anchors matching at the current lastIndex position.
What is ReDoS and how can I detect it?
ReDoS (Regular Expression Denial of Service) occurs when a regex with ambiguous patterns causes the engine to explore an exponentially large number of backtracking paths for certain inputs. Classic examples are nested quantifiers like (a+)+ or overlapping alternatives like (a|aa)+. This tool shows execution time in milliseconds as you type — if a short input suddenly causes a large spike in time, your pattern is likely vulnerable. Simplify the pattern or restructure it to avoid ambiguity before deploying to production.
What are $1 and $2 in replacement strings?
They are backreferences to numbered capture groups. $1 inserts the text matched by the first group, $2 by the second, and so on. For example, applying the pattern (\d{4})-(\d{2})-(\d{2}) to "2024-03-15" and replacing with $3/$2/$1 produces "15/03/2024". Named groups can be referenced as $<name>.
What are named capture groups?
Named groups use the syntax (?<name>pattern) and let you refer to a captured value by a descriptive label instead of a position number. For example, (?<year>\d{4})-(?<month>\d{2}) makes the intent of the pattern clear and allows replacement strings like $<year>/$<month>. Named groups are especially useful in long patterns where counting parentheses is error-prone.
How do lookahead and lookbehind assertions work?
Lookaheads and lookbehinds are zero-width assertions that check the context around a match without including that context in the result. Positive lookahead (?=pattern) matches a position followed by pattern. Negative lookahead (?!pattern) matches a position not followed by pattern. Lookbehinds work similarly: (?<=pattern) and (?<!pattern). For example, \d+(?= dollars) matches only the number in "100 dollars" without capturing the word "dollars".
Is my data sent to a server?
No. Matching runs entirely in your browser's JavaScript engine. You can safely test patterns against internal log data, sensitive configuration strings, or proprietary source code.
