Regex Tester – Online Regular Expression Tester
Use this regex tester to try a regular expression against your own text and see every match and capture group instantly. It uses your browser's JavaScript regex engine, so results match what your code will do.
By DevCalcHub Editorial Team · Last updated:
How it works
This tool compiles your pattern and flags into a JavaScript regular expression, then finds every non-overlapping match in your test string, including any capture groups.
Example
Matching simple email addresses in a string:
How to use the regex tester
- Enter your pattern without the surrounding slashes — for example \d+ rather than /\d+/.
- Add flags if needed: i (ignore case), m (multi-line), s (dot matches newlines), u (Unicode). The g flag is added automatically so you see every match.
- Paste your test text and review the matches, their positions and any captured groups.
Regex cheat sheet
| Pattern | Matches |
|---|---|
| . | Any character except a newline |
| \d / \D | A digit / a non-digit |
| \w / \W | A word character (letter, digit, _) / anything else |
| \s / \S | Whitespace / non-whitespace |
| [abc] / [^abc] | Any of a, b, c / any character except a, b, c |
| ^ / $ | Start / end of the string (or line with the m flag) |
| * / + / ? | 0 or more / 1 or more / 0 or 1 |
| {n} / {n,m} | Exactly n / between n and m times |
| (abc) / (?:abc) | Capturing group / non-capturing group |
| a|b | a or b |
| \b | A word boundary |
| (?=x) / (?<=x) | Lookahead / lookbehind |
Ready-to-use regex patterns for India
| Format | Regex |
|---|---|
| Indian mobile number | ^[6-9]\d{9}$ |
| PIN code | ^[1-9]\d{5}$ |
| PAN card number | ^[A-Z]{5}\d{4}[A-Z]$ |
| GSTIN | ^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$ |
| IFSC code | ^[A-Z]{4}0[A-Z0-9]{6}$ |
| Email (simple) | ^[^\s@]+@[^\s@]+\.[^\s@]+$ |
| Date (YYYY-MM-DD) | ^\d{4}-\d{2}-\d{2}$ |
These patterns check the format only — a matching PAN or GSTIN can still be invalid or unregistered. For the GSTIN, the last character is a checksum that a regex cannot verify.
Tips for writing better regex
- Escape special characters with a backslash when you mean them literally: \. matches a dot, \? a question mark.
- Anchor validation patterns with ^ and $ so the whole string must match, not just part of it.
- Avoid nested quantifiers like (a+)+ — they can cause catastrophic backtracking and freeze on long input.
- Prefer specific character classes over .* where you can.
Need to change the case of identifiers you matched? Try the Case Converter.
Frequently asked questions
Why is the 'g' (global) flag always applied?
Without the global flag, JavaScript's matchAll can't find multiple matches. It's added automatically if you don't include it, so you always see every match in the test string.
Does this tool support lookbehind and other advanced regex features?
Yes — it uses your browser's native regex engine, so any syntax your browser's JavaScript engine supports (including lookaheads/lookbehinds in modern browsers) will work here.
Which regex flavour does this tester use?
JavaScript (ECMAScript). Most syntax is shared with Python, Java and PCRE, but some features differ — for example, JavaScript has no possessive quantifiers or atomic groups.
What is the regex for an Indian mobile number?
^[6-9]\d{9}$ matches a 10-digit Indian mobile number starting with 6, 7, 8 or 9. To also allow an optional +91 prefix, use ^(\+91)?[6-9]\d{9}$.
What is the regex for a PAN card number?
^[A-Z]{5}\d{4}[A-Z]$ — five capital letters, four digits and one capital letter, for example ABCDE1234F.
How do I make a regex case-insensitive?
Add the i flag. With i, the pattern hello matches Hello, HELLO and hello.
Related tools
Input
e.g. i (case-insensitive), m (multiline). 'g' is applied automatically.
2 matches
[14] hello@example.com
[35] support@example.org