Regex Tester

Test regular expressions against sample text. All in your browser.

Try it with this example

Enter \d{3}-\d{4} as the regex and "Call 555-1234 for info" as the test string. See matches and capture groups.

What is this tool?

Regular expressions (regex) are a powerful way to match, search, and replace text patterns. A pattern like \d{3}-\d{4} matches a phone number format (555-1234). Another like ^[a-z]+@[a-z]+\.[a-z]+$ matches a simple email. Regex is used in validation, search-and-replace, log parsing, and text extraction. But writing and testing regex can be frustrating: a small mistake changes the whole match. This Regex Tester lets you try patterns against sample text and see matches, capture groups, and replace results in real time.

Enter your pattern in the regex input and your test string in the text area. Click Test to see which parts of the text match. Enable flags: g for global (all matches), i for case-insensitive, m for multiline (^ and $ match line boundaries). The tool highlights matches in the output and shows capture groups—the parts of the match enclosed in parentheses. If your pattern is \d+(\w+), and the text is "123abc", you'll see that "abc" was captured by group 1. That's invaluable when building extraction logic.

Replace mode lets you test substitution. Enter a replacement string and see the result. Use $1, $2, etc. to reference capture groups. For example, pattern (\d+)-(\d+) with replacement $2/$1 would swap the parts around a hyphen. Testing replacement patterns here avoids surprises in your code. Regex flavors differ slightly between languages; this tool uses JavaScript's RegExp, which is close to the standard used in most web development.

Common use cases include validating input (email, phone, ZIP code), parsing logs or CSV-like data, and cleaning text. Escaping special characters is a frequent gotcha: a dot (.) matches any character unless you escape it as \. The tool helps you catch those errors before deploying. For complex patterns, build them incrementally—start with a simple match, add capture groups, then add alternatives or quantifiers. Seeing the result at each step speeds development.

All processing runs in your browser. No server calls, no limits. Paste sensitive data if needed—it never leaves your device. Keep this tool open when writing validation logic, parsing scripts, or debugging a regex that doesn't quite work. It's one of the most-used utilities for developers who work with text.