| # | Full Match | Capture Groups | Index |
|---|---|---|---|
| No matches yet | |||
Breakdown of your regex pattern into human-readable parts:
Regex Tester & Debugger
What is Regex?
Regular expressions (regex or regexp) are powerful sequences of characters that define search patterns. They are an indispensable tool in programming, used for pattern matching, text searching, data validation, and string manipulation. Virtually every modern programming language supports regular expressions natively or through standard libraries.
A regex pattern can match simple text like a single word, or define complex rules like "an email address format" or "a valid URL." Regex uses special metacharacters such as ., *, +, ?, ^, $, and character classes like \d, \w, \s to create flexible matching rules.
This regex tester lets you write and test regular expressions in real-time. As you type your pattern and test string, matches are instantly highlighted with alternating colors, and detailed information about each match including capture groups and index positions is displayed in a clear table format.
How to Use
- Enter your regular expression pattern in the pattern input field at the top of the tool.
- Select the flags you need: g (global - find all matches), i (case-insensitive), m (multiline), s (dotAll - dot matches newlines).
- Type or paste your test string in the text area on the left.
- View highlighted matches in real-time on the right, with alternating colors for each match.
- Examine the match table below for detailed information: match number, full match text, capture groups, and character index.
- Switch to the Replace tab to test find-and-replace operations using capture group references like
$1,$2. - Use the Explain tab to see a human-readable breakdown of what each part of your regex does.
- Click the Common Patterns buttons to load pre-built regex patterns for common use cases.
Common Patterns Reference
| Pattern | Description | Example Match |
|---|---|---|
| [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} | Email address | user@example.com |
| https?://[^\s]+ | URL (HTTP/HTTPS) | https://example.com |
| \b\d{3}[-.]?\d{3}[-.]?\d{4}\b | US Phone Number | 123-456-7890 |
| \b\d{1,3}(\.\d{1,3}){3}\b | IPv4 Address | 192.168.1.1 |
| #[0-9a-fA-F]{3,8}\b | Hex Color Code | #ff5733 |
| \b\d{4}[-/]\d{2}[-/]\d{2}\b | Date (YYYY-MM-DD) | 2024-01-15 |
Frequently Asked Questions
What regex flavor does this tool use?
This tool uses JavaScript's native RegExp engine, which implements the ECMAScript regular expression specification. This is the same regex engine used in all modern web browsers and Node.js. Features like lookbehind assertions are supported in modern browsers but may not work in older ones.
What do the regex flags mean?
g (global): Find all matches rather than stopping at the first one. i (case-insensitive): Makes the pattern match regardless of letter case, so /a/i matches both "a" and "A". m (multiline): Changes ^ and $ to match the start/end of each line instead of the entire string. s (dotAll): Makes the dot (.) character match newline characters as well, allowing patterns to span multiple lines.
How do capture groups work in the replacement?
Capture groups are parts of your regex enclosed in parentheses. In the replacement string, you can reference them using $1, $2, $3, etc., where the number corresponds to the group's position. Use $& for the entire match. For example, with the pattern (\w+)@(\w+) and replacement $1 at $2, the match "user@domain" becomes "user at domain".
Is my data sent to any server?
No. All regex matching is performed locally in your browser using JavaScript's built-in RegExp engine. Your patterns and test strings never leave your device, making this tool completely private and safe for testing with sensitive data such as passwords, personal information, or proprietary text.