Regex Tester & Visualizer - Test Regular Expressions Online
123 uses
Email
URL
IPv4
Hex Color
Date
Phone
HTML Tag
Tips
Global Flag
Enable the g flag to find all matches, not just the first one
Case Insensitive
Use the i flag to match regardless of letter case
Capture Groups
Use parentheses () to create capture groups and extract parts of matches
Quick Start
Click any preset to load a common regex pattern instantly
Frequently Asked Questions
Does the regex visualizer support lookbehind assertions?
Yes, lookbehind assertions work here. You can use both fixed-length (?<=pattern) and (?<!pattern) forms. Variable-length lookbehinds like (?<=ab+) also work in this JavaScript-based engine. Just paste a pattern like (?<=@)\w+ to extract usernames from emails. One tip: if your lookbehind isn't matching, check if the 'u' flag is enabled — some Unicode patterns need it.
Is there a way to see step-by-step how my regex matches against the test string?
Yes, click the 'Debug' button next to the test area. This breaks the matching process down character by character. You'll see the engine enter and exit each token — quantifiers, groups, character classes — one step at a time. For example, testing /\d{3}-\d{4}/ against '555-1234' shows exactly where the engine backtracks. This is gold when you're debugging complex patterns or JWT token validation rules.
What happens if I paste a regex with catastrophic backtracking?
The tool will warn you with a timeout notice after about 2 seconds. You'll see the test string turn gray and a 'Pattern took too long' message appear. This happens when nested quantifiers like (a+)+b try every possible path before failing. Click 'Stop' to abort. Then simplify your pattern — replace nested groups with atomic groups (?>...) or use possessive quantifiers. A classic fix: turn (\d+)+ into \d+.
Can I share my regex patterns and test strings with my team?
Yes, just copy the URL from your browser's address bar after you've entered your regex and test text. That URL contains your entire session — pattern, flags, test string, everything. Share it with a coworker and they'll see exactly what you see. Great for pair debugging or code reviews. One catch: very long patterns might make the URL unwieldy, so keep your test strings reasonable.
Is regex case-sensitive by default?
Yes, regular expressions treat uppercase and lowercase as completely different characters without the 'i' flag. For instance, /hello/ won't match 'Hello' or 'HELLO' in your test string. Toggle the 'i' flag to make it case-insensitive, then you'll see all three variations highlighted. Many developers assume regex is case-insensitive by default, but it's not. Always check your tool's flag panel to confirm. Pro tip: use the preset dropdown to load common patterns and see how flags affect them instantly.
Does highlighting update when I type in real time?
Yes, it updates as you press each key. The test string instantly reflects your changes—no button clicking needed. This live feedback loop speeds up pattern debugging by a lot. For backend devs working with JSON payloads, this means you can tweak a regex and see results against sample API responses in under a second. Word of caution: extremely long test strings (10,000+ characters) may introduce a brief lag, so break large datasets into smaller chunks first.
Why does my regex work in the tool but fail when I paste it into JavaScript code?
Most likely a flag mismatch. The tool defaults to 'g' enabled, but your runtime might use plain new RegExp(pattern) without flags. Add the 'g' flag in your code to match what you see here. Another culprit: literal versus variable patterns. If you wrapped your pattern in slashes like /\d+/g, those slashes are syntax, not part of the regex. Copy the pattern from the input box directly, not from a tutorial. I'd also check for trailing whitespace—it's invisible but breaks the match.
Can I test regex patterns for form validation without writing code?
Yes, paste a real-world value like an email or phone number into the test string, then load the matching preset from the dropdown. You'll see immediately if the pattern accepts or rejects it. For a UK postcode, try the 'Postal Code' preset and swap in 'SW1A 1AA'—the highlight shows you the exact match boundary. This beats writing a quick script every time you need to validate a new field. One tip: test edge cases like 'user@domain' (missing TLD) to catch false positives before your client does.
Exporting regex patterns to backend configuration files
You can export your tested regex directly into various programming languages by clicking the 'Export' button in the top right corner. Select Node.js, Python, or PHP from the modal. The tool formats the escaped backslashes automatically so you don't get syntax errors in your production code. Copy the snippet and paste it right into your project's routing file.
How many capture groups can I view simultaneously in the sidebar?
The sidebar handles up to 32 numbered capture groups without performance drops. Paste a complex log line with multiple timestamps, IP addresses, and user IDs to watch the parser split them out instantly. Group one holds your first parenthesis set, while group 32 catches the final match segment. Try hovering over any group box to see its exact character offset highlighted in the main test window.
How to Use the Regex Tester
- Enter your regular expression pattern in the pattern field
- Toggle the desired flags (g, i, m, s, u)
- Type or paste your test string in the text area
- Matches are highlighted in real time
- View match details and capture groups below
- Click a preset to load common patterns like Email or URL