Enter the required information
Use the fields in the tool above and keep units and formats consistent.
Test regular expressions on your own sample text, see each match and capture group, and spot greedy or unanchored patterns before they reach your code.
A regex that looks right can still match too much, too little or nothing at all. Running it against real sample text is the fastest way to find out. A regex tester highlights matches as you type, lists captured groups and lets you toggle flags. You catch the awkward edge cases before your users do.
\d{6} for a six-digit PIN code.g for every match or i to ignore case.| Token | Meaning | Example |
|---|---|---|
. | Any character except a line break | a.c matches abc and a-c |
\d | A digit from 0 to 9 | \d\d matches 42 |
\w | Letter, digit or underscore | \w+ matches user_1 |
\s | Whitespace | Space, tab or newline |
^ and $ | Start and end of the string | ^Hi$ matches only Hi |
*, +, ? | Zero or more, one or more, optional | colou?r matches both spellings |
{2,4} | Between two and four repeats | \d{2,4} matches 123 |
[abc] | Any one listed character | [aeiou] matches vowels |
(...) and (?:...) | Capturing and non-capturing groups | (\d{4}) saves a year |
a|b | Either side | cat|dog |
^ and $ work on each line, not only the whole text.\p{L}.These are starting points, not bulletproof validators. Adjust each one to your exact business rules.
| Data | Pattern | Notes |
|---|---|---|
| Mobile number | ^[6-9]\d{9}$ | Ten digits starting 6-9, no +91 |
| PIN code | ^[1-9]\d{5}$ | Six digits, first digit not zero |
| PAN | ^[A-Z]{5}\d{4}[A-Z]$ | Five letters, four digits, one letter |
| GSTIN shape | ^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$ | Does not verify the check character |
| Date (DD/MM/YYYY) | ^\d{2}/\d{2}/\d{4}$ | Accepts 31/02/2025, so validate dates in code |
| Email (simple) | ^[^\s@]+@[^\s@]+\.[^\s@]+$ | Catches typos, not every valid address |
Email is the classic trap. The full address grammar is far too complex for a practical pattern. A simple shape check plus a confirmation email works better in real forms.
example.com matches any character. Write example\.com instead.<.+> runs from the first < to the very last >. The lazy form <.+?> stops early.^ and $, a pattern matches inside longer strings. An 11-digit number still contains a valid-looking mobile number.new RegExp() string, \d must be written as \\d.Nested quantifiers such as (a+)+$ can force the engine through millions of paths on a failing input. The browser tab freezes or the server stalls. This weakness is known as ReDoS, a form of denial of service. If a test hangs on a short string, flatten the nesting or use atomic groups where your flavour supports them.
Browser-based testers, the ToolsMate regex tester included, normally rely on the JavaScript engine. Recheck any pattern in your target language before shipping it.
Use the fields in the tool above and keep units and formats consistent.
Review the result shown in the output area.
Confirm that the result matches your situation before using it for a decision.
The first line is treated as the regular expression and remaining lines as test text.This describes the core logic used by the tool. Check any assumptions that may affect your result.
Use accurate inputs and keep units consistent.
Review the assumptions before using the result for a decision.
Compare important results with an independent or official source.
Most browser-based testers run JavaScript's built-in RegExp engine. That closely matches Node.js behaviour but differs from Python, PHP and Java in places. Lookbehind support, named group syntax and Unicode handling are the usual areas to recheck.
Put a backslash in front of it. Write \. for a dot, \( for a round bracket and \[ for a square one. Inside a character class such as [.], most special characters lose their meaning, so the dot needs no escape there.
Greedy quantifiers like .* grab as much text as possible, then give some back if needed. Lazy versions like .*? take as little as possible. For pulling text from between quotes or tags, the lazy form usually gives the result you want.
Use ^[6-9]\d{9}$, which requires ten digits beginning with 6, 7, 8 or 9. To allow an optional +91 or 0 prefix, try ^(?:\+91|0)?[6-9]\d{9}$ instead. Strip spaces and hyphens from user input before testing it.
Escaping usually changes when the pattern moves into a quoted string. Many languages need every backslash doubled there. Also confirm the same flags carried over. Then check your language supports each feature, such as lookbehind or named groups.
Capture groups, written with round brackets, save part of a match for later. You might extract the year from a date, or reuse a group in a replacement as $1 or \1. Use (?:...) when you need grouping without saving anything.
Not reliably. HTML allows nesting, optional closing tags and attributes in any order, which regular expressions cannot fully model. Regex is fine for quick extraction from predictable markup. For anything dependable, use a real parser such as DOMParser or BeautifulSoup.
Explore other useful tools across the site.