TestingAPIs is still being built. If something breaks, email support@testingapis.com.

Regex tester

Runs in your browser; nothing is uploaded

Test JavaScript regular expressions against your text, with capture groups and replacement.

Test text

Type a pattern

Matches are listed here with their position and capture groups. Patterns use JavaScript's RegExp, as in browsers and Node.js; type them without the surrounding slashes.
Type a pattern
/gLn 1, Col 1

What is a regular expression?

A regular expression, or regex, is a pattern that describes a set of strings. \d{3} means three digits, [a-z]+ one or more lowercase letters, and ^ and $ anchor a match to the start and end. Programs use patterns to find, extract, validate and replace text.

Parts of a pattern in parentheses are capture groups. In (\d{4})-(\d{2}) matched against 2025-07, group 1 is 2025 and group 2 is 07. Named groups such as (?<year>\d{4}) let you refer to a part by name. Flags change how the whole pattern behaves: i ignores case and g finds every match instead of only the first.

This tester runs JavaScript's RegExp, the engine in browsers and Node.js, so a pattern that works here works the same in JavaScript and TypeScript. Other languages share most of the syntax but not all of it; the questions below list the differences that come up most.

How to use this tool

  1. 1Type a pattern in the box between the slashes, without the slashes themselves. Presets loads a pattern with sample text.
  2. 2Turn flags on and off in the toolbar: g global, i ignore case, m multiline, s dotAll, u and v Unicode modes, y sticky and d group indices. Hover a flag to see what it does.
  3. 3Paste the text to search in Test text, or drop a file on it. Matches are highlighted as you type and listed under Matches with their line, column and capture groups.
  4. 4Click a match, or press Enter in the pattern box (F7 elsewhere), to select it in the text and see its groups highlighted. Shift+Enter or Shift+F7 goes back.
  5. 5Open Replace to try a replacement such as $2/$1 or $<year> and see the result. Apply to test text writes it into the text; Ctrl+Z undoes it.

Troubleshooting

Stopped after 2 seconds
The pattern backtracks catastrophically on this text: nested quantifiers such as (a+)+ or (.*,)* try exponentially many ways to match before failing. Make each repeated part match only one way, for example [^,]* instead of .*. The same pattern can freeze a server, which is why it is stopped here.
The pattern works in code but not here, or the other way round
In a string literal in code, every backslash is written twice ("\\d+"). Here you type the pattern itself, with single backslashes (\d+), as between the slashes of /\d+/.
Only one match is found
The g flag is off. Without it the search stops after the first match, and Replace changes only the first one.
^ or $ match only once
Without the m flag they match only at the very start and end of the whole text. Turn on m to match at every line.
Invalid escape or invalid group with the u flag
Unicode mode is stricter: escapes that mean nothing, such as \- outside a character class, become errors. Remove the backslash, or turn off u.

Frequently asked questions

How does JavaScript's regex differ from PCRE, Python or Java?

JavaScript has no possessive quantifiers (a++) or atomic groups ((?>…)), no \A and \Z (use ^ and $ without the m flag), and no (?i) at the start of a pattern: set flags with the toggles instead. Python writes named groups (?P<name>…) where JavaScript writes (?<name>…). Lookbehind, named groups and Unicode property escapes such as \p{L} (with u or v) are supported in current browsers.

What is the difference between the m and s flags?

m (multiline) makes ^ and $ match at the start and end of each line. s (dotAll) makes . match line breaks too; without it . matches any character except a line break.

Is the email preset a complete email validator?

No. It finds the common name@domain.tld shape in text, which is what you usually want when searching logs or responses. The full address standard allows much more. To validate an address, check the basic shape and then send a confirmation email.

Is my text sent to a server?

No. Matching runs in your browser, in a background worker of this page, and nothing is uploaded. To survive a reload, the pattern and text are kept in this tab's session storage until you clear it or close the tab. Copy link puts the input in the link after #, which browsers never send to a server, but anyone you give the link to can read it.