Rates TodayNIFTY25,144.3+0.46%SENSEX81,592.5+0.70%Gold 24K ₹12,589.84/g down152.83Silver ₹161.52/g down3.95
InsightforGeeks

Regex Tester

Type a regular expression and some test text to see every match highlighted, with its position and capture groups. You can also preview a find-and-replace. It uses the JavaScript regex engine and runs in your browser, with protection against patterns that would hang the page.

//g
Quick reference
.any character (not a line break)
\d \w \sdigit, word character, whitespace
[abc] [^abc] [a-z]one of, none of, a range
^ $start, end of the text (or line with m)
* + ? {2,4}0 or more, 1 or more, optional, 2 to 4 times
*? +?lazy: as few as possible
(abc) (?:abc)capturing group, non-capturing group
(?<name>abc)named group, read as $<name>
a|ba or b
\bword boundary
(?=a) (?!a)followed by a, not followed by a
(?<=a) (?<!a)preceded by a, not preceded by a

How to use it

  1. Enter your pattern between the slashes and choose the flags you need. g finds all matches, and i ignores case.
  2. Type or paste the test text. Matches are highlighted as you type, and the table lists each match with its position and groups.
  3. To preview a replacement, enter text in “Replace with”. Use $1 or $<name> to insert captured groups.

Frequently asked questions

Which regex flavour does this use?

The JavaScript (ECMAScript) flavour that runs in your browser. It matches what you get in JavaScript, TypeScript and Node.js. Other languages such as Python, Java and PCRE differ in some features, for example lookbehind support and inline flags.

What do the flags mean?

g finds all matches instead of the first, i ignores upper and lower case, m makes ^ and $ match at each line, s lets the dot match line breaks, u turns on full Unicode support, and y matches only at the current position (sticky).

Why does my pattern stop with a timeout message?

Some patterns, usually with nested repeats like (a+)+ against text that almost matches, can take exponential time. The tool stops them after two seconds so your browser stays responsive. Rewrite the pattern to avoid ambiguous repeats.

How do I match a literal dot or bracket?

Put a backslash in front of the character, for example \. for a dot, \( for an opening bracket or \\ for a backslash. Inside a character class, most special characters lose their special meaning.

Is my text uploaded?

No. Everything runs in your browser.

Related tools

These tools run entirely in your browser and are provided free, without warranty. Check important results before using them in production.