Regex Tester: Test Regular Expressions Online
Test and debug regular expressions in real time with match count, captured group inspection, and string replacement.
Privacy First: 100% Client-Side Processing
Processed in your browser. Files are never uploaded.
How to Use the Regex Tester & Debugger (JavaScript RegEx)
- 1Enter your regular expression pattern into the pattern input.
- 2Select or customize regex flags (e.g., 'g' for global match, 'i' for case-insensitive).
- 3Type or paste your sample test text into the test box.
- 4Review the total match count, indices, and captured group values.
- 5Optionally enter replacement text to test string substitutions.
Formula & How It Works
ECMAScript RegExp Engine
Executes standard JavaScript RegExp engine matches with safe loop termination on zero-length matches.
Worked Examples
Extracting Email Addresses
Input: Pattern: ([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})
Explanation: Extracts email usernames into Group 1 and domain names into Group 2.
Finding Phone Numbers
Input: Pattern: \b\d{3}[-.]?\d{3}[-.]?\d{4}\b
Explanation: Matches formats like 555-123-4567 and 5551234567.
Case-Insensitive Global Word Match
Input: Pattern: \bcat\b, Flags: gi
Explanation: Word boundary \b ensures 'scatter' is not matched.
Frequently Asked Questions
What does the 'g' flag do in regex?▼
The 'g' (global) flag tells the regular expression engine to find all matches across the entire string rather than stopping at the first match.
What does the 'i' flag do?▼
The 'i' (ignore case) flag makes matches case-insensitive, treating uppercase and lowercase letters as identical.
How do you match a literal period (.)?▼
Because a period is a wildcard matching any character, you must escape it with a backslash: \.
Does this tester support captured groups?▼
Yes, all parenthesized capture groups ($1, $2, etc.) and named groups are listed with exact match indices.
Is this tool secure?▼
Yes, all regular expression evaluations run in your browser sandbox with loop-protection against catastrophic backtracking.
Quick Reference & Conversion Table
| Meta-character | Meaning | Example | Matches |
|---|---|---|---|
| \d | Any digit (0-9) | \d{3} | 123 |
| \w | Any word character (a-z, A-Z, 0-9, _) | \w+ | User_12 |
| \s | Any whitespace (space, tab, newline) | \s+ | Spaces |
| [abc] | Any character inside brackets | [aeiou] | Any vowel |
| ^ / $ | Start / End of string | ^Start | Lines starting with Start |
⚠️ Common Pitfalls to Avoid
- •Forgetting the global flag 'g' (without 'g', the regex stops evaluating after finding the very first match).
- •Failing to escape special regex meta-characters like ., *, +, ?, [, ], (, ), and $ with backslashes.
- •Writing greedy quantifiers that match too much text (use non-greedy *? or +? when matching between tags).
💡 Practical Real-World Uses
- •Validating user input forms (emails, URLs, phone numbers, passwords).
- •Log file parsing, security audit filtering, and web scraping.
- •Search-and-replace text batch processing in code editors.
Greedy vs Lazy (Non-Greedy) Matching
- ✓Greedy matchers (*, +) match as much text as possible before stopping.
- ✓Lazy matchers (*?, +?) match as little text as possible, stopping at the very first valid boundary.
Related Online Tools
Explore complementary calculators and converters with instant client-side execution
XML Formatter & Beautifier (Syntax Validator)
Format, beautify, and minify XML code with 2-space or 4-space indentation and tag validation.
JSON Formatter & Validator (Beautify, Minify & Repair)
Format, beautify, validate, and minify JSON strings with instant syntax error detection and customizable indentation.
Subnet Calculator (IPv4 CIDR & Network Mask)
Calculate IPv4 subnets, CIDR masks (/0 to /32), network/broadcast IDs, and usable IP host ranges with binary breakdowns.
Diff Checker (Text Comparison & Difference Highlighter)
Compare two text files or snippets to highlight additions, deletions, and line-by-line differences instantly.
Case Converter – UPPER, lower, camelCase, Title
Transform text casing into UPPER, lower, Title Case, Sentence case, camelCase, snake_case, and kebab-case instantly.
Sentence Counter – Words, Sentences & Readability
Count sentences, words, paragraphs, and characters with reading time and readability metrics.
Explore Other Tool Categories
Browse our full collection of 50 free web utilities
Unit Converters
Exact metric & imperial conversions for weight, length, temperature & volume.
Math & Education
Percentage changes, fractions, square roots, geometry & statistics.
Date & Time
Calendar arithmetic, business day intervals, stopwatch & multi-counter.
Home & Construction
Paint coverage, pool volume, topsoil, roof pitch, square footage & materials.