Test JavaScript regular expressions against your text with match counts, positions, and capture groups. Invalid patterns show clear errors. Free, no signup, runs locally.
What is the Regex Tester?
A regex tester lets you experiment with regular expressions — compact patterns that match text — against real input, showing every match, its position, and captured groups. This regex tester online evaluates patterns with the JavaScript RegExp engine, the same engine that runs in browsers and Node.js, so a pattern that works here works in your code.
Type your pattern in the second box and your test string in the first. Flags like g (find all matches), i (case-insensitive), and m (multiline) go in the flags field. The results table lists each match with its index, so you can verify boundary cases — does \b\d{4,}\b catch the 5-digit order number but skip the year inside the date? You will see instantly.
Invalid patterns do not fail silently: you get the engine’s exact error message, which usually points at an unclosed group or a stray quantifier. Everything evaluates locally in your browser — paste log samples and production data freely with no signup and nothing uploaded.
When a pattern misbehaves, bisect it. Test half the pattern, confirm which half matches, then grow from the working side — the match table makes each step visible. Most regex bugs come from three places: an unescaped special character, a greedy quantifier eating too much, or missing anchors letting partial matches through. Check those first and you will solve the majority of issues in minutes.
How to use the Regex Tester
- Paste the text you want to search into the first box.
- Type your regular expression into the pattern box (without the surrounding / slashes).
- Add flags if needed: g for all matches, i to ignore case, m for multiline, s for dot-all.
- Click Test Regex to see the match count and a table of every match with its position.
- Refine the pattern and re-run until it matches exactly what you intend — then copy it into your code.
Regex Tester use cases
Validating input formats
Email checks, phone numbers, postal codes, and password rules are classic regex jobs. Test the pattern against valid and invalid samples here before shipping it in a form validator.
Extracting data from logs
Pull order IDs, timestamps, or error codes out of log lines with capture groups. The match table shows each hit and its index, making it easy to confirm the pattern against messy real data.
Building search-and-replace rules
Before running a regex replace across a codebase, verify the match set here — a greedy .* can swallow far more than intended, and the table makes over-matching obvious.
Learning regular expressions
Regex is best learned by doing. Tweak one token at a time — \d vs \w, * vs +, greedy vs lazy — and watch the match list change to build real intuition.
Tips
- Start with the g flag so you see all matches, not just the first one.
- Anchor with ^ and $ when the whole string must match, not just part of it.
- Prefer lazy quantifiers (*? and +?) when a greedy match swallows too much text.
- Test against inputs that should NOT match — a pattern is only correct if it also rejects correctly.