Regex Tester
Regular expressions are indispensable for searching, validating, and transforming text, but building them correctly often means hours of trial and error. This free regex tester lets you write a pattern, choose your flags, and instantly see every match highlighted in your test string. Pair it with the JSON Formatter when extracting patterns from API responses. Each match displays its index position and any captured groups, so you can verify that your parentheses extract exactly the data you need. Toggle the global, case-insensitive, multiline, and dotAll flags with checkboxes instead of memorizing syntax. Building regex for URL validation? Encode test URLs with the URL Encoder / Decoder to see how special characters transform. Invalid patterns surface clear error messages inline, helping you fix typos before they reach production code. Everything runs locally in your browser using the native JavaScript RegExp engine — no data is transmitted, no account is required, and results update in real time as you type.
How to Use This Tool
- Enter your regular expression pattern in the pattern input field. Do not include the surrounding slashes — just the pattern itself.
- Select the flags you need: global (g) for multiple matches, case-insensitive (i), multiline (m) for line-by-line anchoring, or dotAll (s) to make the dot match newlines.
- Paste or type your test string into the textarea. Matches highlight in real time as you type both the pattern and the test string.
- Review the highlighted output and the match details list below it. Click Copy Matches to copy all match data to your clipboard.
Examples
Extract Email Addresses
Pattern
[\w.+-]+@[\w-]+\.[\w.]+
Test string
Contact us at support@example.com or sales@company.co.uk
Result
2 matches: "support@example.com" at index 17, "sales@company.co.uk" at index 41
Parse Dates with Captured Groups
Pattern
(\d{4})-(\d{2})-(\d{2})Test string
Released on 2024-01-15 and updated on 2024-06-30.
Result
2 matches with groups: "2024", "01", "15" and "2024", "06", "30"
Validate IP Addresses
Pattern
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\bTest string
Server 192.168.1.1 responded, but 10.0.0.255 timed out.
Result
2 matches: "192.168.1.1" at index 7, "10.0.0.255" at index 33
What This Tool Is Useful For
- Form validation: Test email, phone number, or postal code patterns before embedding them in front-end or back-end validation logic.
- Log parsing: Build patterns that extract timestamps, error codes, or IP addresses from raw log files quickly.
- Data extraction: Prototype regex for scraping structured data from HTML, CSV, or plain text before writing the full script.
- Search and replace: Verify that a pattern matches exactly the right substrings before running a global find-and-replace in your editor or codebase.
- Learning regex: Experiment with different patterns and flags in real time to build intuition about how regular expressions work.
Frequently Asked Questions
- Does this regex tester support all JavaScript regex features?
- Yes. The tool creates a native JavaScript RegExp object in your browser, so every feature your browser supports — including named groups, lookbehind assertions, and Unicode property escapes — works here. The available flags are global (g), case-insensitive (i), multiline (m), and dotAll (s).
- Why does my pattern show zero matches even though it looks correct?
- The most common reasons are a missing global flag when you expect multiple matches, or a case mismatch when the case-insensitive flag is off. Check that your flags are set correctly. Also verify that special characters like parentheses, brackets, or dots are escaped with a backslash if you intend them as literals.
- Is my test data sent to a server?
- No. All matching happens locally in your browser using JavaScript's built-in RegExp engine. No patterns, test strings, or results leave your device.
- What are captured groups and when should I use them?
- Captured groups are portions of a match enclosed in parentheses in your pattern. For example, (\d{3})-(\d{4}) applied to '555-1234' produces two groups: '555' and '1234'. Groups are useful for extracting specific parts of a match, such as pulling the domain from an email address or the year from a date string.
- How do I match across multiple lines?
- Enable the multiline (m) flag so that ^ and $ match the start and end of each line rather than the entire string. If you also need the dot (.) to match newline characters, enable the dotAll (s) flag as well.
More Developer Tools
Generate secure credentials with the Password Generator. Format and validate structured data with the JSON Formatter & Validator. Encode binary data with the Base64 Encoder / Decoder. Create unique identifiers with the UUID Generator. Browse all utilities in the Developer Tools hub.
Related Tools
JSON Formatter
Format, validate, and beautify JSON data with syntax highlighting.
Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 strings back to plain text.
Password Generator
Generate strong, random passwords with customizable length and character sets.
UUID Generator
Generate random UUIDs (v4) and nil UUIDs instantly for your applications.