We use essential cookies to keep you signed in and protect forms. We also use analytics to count visits and see how pages are used. Ads on our free tools may set cookies to show and measure ads. Cookie notice
Regex Tester
Try a pattern against your text and see every match. Heavy patterns are stopped instead of freezing your tab.
Your files stay with you. Your files never leave your browser. This tool runs on your device: nothing is uploaded to our servers, so there is nothing for us to store or see.
How to use it
1Type your pattern (without slashes) and tick the flags you need.
2Paste or edit the test text.
3Read the highlighted matches and the groups table.
Where it helps
Validation
Check a pattern for phone numbers, PIN codes or GSTINs before using it.
Find and replace
Build a pattern for a bulk edit in your editor or spreadsheet.
Log digging
Pull IDs, dates or errors out of a block of log text.
Good to know
Stays in your browser
Your text and files are processed on your device and never sent to our servers.
JavaScript flavour
PCRE and Python differ in places such as lookbehind.
Type your pattern without the slashes, tick the flags you need (g, i, m, s or u) and paste or edit the test text. Every match is highlighted and a table lists the capture groups. The test runs in a background worker that stops after 1.5 seconds, so a runaway pattern can't freeze your tab. It uses JavaScript regex syntax.
LiveHighlights.As you type.
GroupsTable.First 200 matches.
5Flags.g i m s u.
1.5 sTime limit.No frozen tabs.
Which regex flavour is this?
JavaScript (ECMAScript) regular expressions, as used in browsers and Node.js. Other flavours such as PCRE, used by PHP, or Python's re module differ slightly, for example in lookbehind support and named group syntax. Most everyday patterns work the same, but test in your target language too.
Why does it say the pattern took too long?
Some patterns, like (a+)+$, can take exponential time on certain text, a problem known as catastrophic backtracking. The test runs in a background worker that's stopped after 1.5 seconds, so your page keeps working. Make the pattern more specific, for example by removing nested repeats.
What do the flags mean?
g finds all matches instead of the first, i ignores case, m makes ^ and $ match at the start and end of each line, s lets the dot match new lines and u turns on full Unicode handling. Tick the ones you need; they work the same way as the letters after the closing slash in code.
Is my text uploaded?
No. Your pattern and text are processed in your browser and never sent to our servers or stored. That makes it safe to test against real log lines, customer data or internal text. Close the tab when you're done if you're on a shared computer.
How do I match an Indian mobile number?
A simple pattern is ^[6-9]\d{9}$, which matches ten digits starting with 6, 7, 8 or 9. To allow an optional +91 or 0 in front, use ^(?:\+91|0)?[6-9]\d{9}$. Paste some real numbers as test text, one per line, and tick m to check each line separately.
How do I match a PIN code or GSTIN?
An Indian PIN code is ^[1-9]\d{5}$: six digits not starting with 0. A GSTIN has 15 characters in a set pattern of state code, PAN, entity number, Z and a check character. A regex checks the shape only; use the GSTIN validator tool for the checksum.
Why do I need to escape some characters?
Characters such as . * + ? ( ) [ ] { } ^ $ | and \ have special meanings in regex. To match them literally, put a backslash before them, so \. matches a real full stop. Forgetting this is the most common reason a pattern matches far more text than you intended. The quick reference in the tool lists the special characters.
What are capture groups?
Parentheses in a pattern capture the part of each match inside them, so you can reuse it, for example to pull the domain from an email address. The groups table shows each group's value for every match. Use (?:...) when you need grouping without capturing anything.
How do named groups work?
Write (?<name>...) to give a group a name, such as (?<year>\d{4}). The groups table lists every group by number, as $1, $2 and so on, in the order they open, while in JavaScript code you can read a named one from match.groups.year. Names make long patterns much easier to read and maintain.
What is the difference between greedy and lazy?
Quantifiers like * and + are greedy: they match as much as possible. Adding ? makes them lazy, matching as little as possible. On '<b>one</b><b>two</b>', <b>.*</b> matches everything, while <b>.*?</b> matches each tag pair separately. The highlights here make the difference obvious. Lazy quantifiers are often what you want when matching tags or quoted text.
Why does my pattern not match across lines?
By default the dot doesn't match a line break, and ^ and $ match only at the very start and end of the text. Tick s to let the dot match new lines, and m to make ^ and $ work on each line. Most multi-line surprises come down to these two flags.
Can I use lookahead and lookbehind?
Yes. JavaScript supports lookahead (?=...) and (?!...) and lookbehind (?<=...) and (?<!...) in all current browsers. They check what comes before or after a match without including it. For example, (?<=₹)\d+ matches the number after a rupee sign but not the sign. They're handy for pulling out values that sit next to a fixed label or symbol.
Should I validate email addresses with regex?
Only loosely. A simple pattern such as ^[^\s@]+@[^\s@]+\.[^\s@]+$ catches obvious typos. Fully correct email regex is extremely long and still can't tell whether the mailbox exists. Sending a confirmation email is the only real check that an address works. Keep the pattern simple and let the confirmation email do the rest.
Does it work on a phone?
Yes. Type the pattern and test text on your phone and the matches highlight as you type. Typing special characters is slower on a phone keyboard, so complex patterns are easier on a computer, but everything runs locally in the mobile browser. Results update as you type.
Is the regex tester free?
Yes. It's free with no sign-up and no limit on use. It's one of the free developer tools from Marketiism, along with the JSON formatter and the cron explainer. Marketiism builds software that runs WhatsApp, billing and a CRM for small businesses. Use it as often as you need.
Want this inside your own account?
Marketiism keeps your invoice numbers, GST reports, UPI payment links and WhatsApp reminders in one place. Leave your details and we'll call to set it up for your business, or start the trial yourself.