Test a regular expression against a string and see every match, with capture groups.
The pattern and flags you type are passed straight to the browser's built-in RegExp constructor. If the browser rejects the pattern, for example because a bracket is not closed, its own error message is shown above the results so you can see exactly what it objected to.
With the g flag, the tool collects every match in the test string. Without it, only the first match is reported. Each row of the result table shows the matched text, the index where it starts, and the value of each capture group in order. The index counts characters from zero, so a match at the very start of the text has index 0.
Because the pattern is typed into a text box rather than written inside JavaScript source code, you type each backslash once. Write \d, not the doubled form you would need inside a quoted string in code.
Say you want to find dates written as DD/MM/YYYY, the format most Indian documents use, and separate the day, month and year. Enter this pattern with the flag g:
(\d{2})/(\d{2})/(\d{4})Test string: Invoice dated 15/08/2026, paid on 02/10/2026.
| # | Match | Index | Groups |
|---|---|---|---|
| 1 | 15/08/2026 | 14 | 15, 08, 2026 |
| 2 | 02/10/2026 | 34 | 02, 10, 2026 |
Remove the g flag and only the first row appears. Note that this pattern checks the shape of the text, not whether the date is real: 31/02/2026 would also match. Checking calendar validity is a job for code, not for a regular expression.
| Token | Meaning |
|---|---|
\d / \D | A digit 0 to 9 / any character that is not a digit |
\w | A basic Latin letter A to Z or a to z, a digit or an underscore. It does not match Hindi or other non-Latin letters. |
\s | A space, tab or line break |
. | Any character except a line break (including line breaks with the s flag). To match a real full stop, write a backslash before it. |
^$ | Start and end of the text, or of each line with the m flag |
\b | A word boundary, useful to avoid matching inside a longer word or number |
[abc][^abc] | Any one of the listed characters / any character not listed |
*+? | Zero or more, one or more, zero or one of the previous item. Add ? after them to make them match as little as possible. |
{n}{n,m} | Exactly n times, or between n and m times, written with curly braces |
( )(?: ) | A capture group, shown in the Groups column / a group that does not capture |
a|b | Either the left side or the right side |
These patterns check that a value has the right shape. Paste one into the pattern box, leave the flags empty, and test a single value. They do not prove that a number was actually issued; the GSTIN pattern, for example, does not verify the final check character.
| Value | Pattern | Rule it checks |
|---|---|---|
| Mobile number | ^[6-9]\d{9}$ | 10 digits starting with 6, 7, 8 or 9, without the +91 prefix |
| PIN code | ^[1-9]\d{5}$ | 6 digits, first digit not zero |
| PAN | ^[A-Z]{5}\d{4}[A-Z]$ | 5 capital letters, 4 digits, 1 capital letter, such as ABCDE1234F |
| IFSC | ^[A-Z]{4}0[A-Z0-9]{6}$ | 4-letter bank code, a zero, then a 6-character branch code |
| GSTIN | ^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$ | 15 characters: state code, the holder's PAN, an entity number, the letter Z and a check character |