Regex Tester

Test JavaScript regular expressions with live highlighting, capture groups and replace.

Runs in your browser — nothing you enter is sent to our servers

//
Flags
Matches highlighted

How it works

Your pattern and flags are compiled with JavaScript’s RegExp. Matching runs in a background Web Worker with a 1.5-second limit, so a runaway pattern can’t lock up the page. Matches are highlighted in the test string, and the table lists each match’s position with its numbered and named capture groups. The replace box uses String.prototype.replace with the same pattern.

Quick reference

\d \w \sdigit, word character, whitespace (capitals negate: \D \W \S)
. ^ $any character, start, end
* + ? {2,4}0+, 1+, 0 or 1, between 2 and 4 (add ? to make lazy)
[abc] [^abc]any of / none of a, b, c
(…) (?:…) (?<name>…)capture group, non-capturing group, named group
(?=…) (?!…)lookahead, negative lookahead

Example

The pre-filled pattern matches South African phone numbers written as 082 123 4567 or 021-555-0199, capturing the area code as a named group. The replacement ($<area>) $2-$3 reformats them as (082) 123-4567 and (021) 555-0199. The “invalid” number doesn’t match.

Frequently asked questions

Which regex flavour does this use?

JavaScript (ECMAScript) regular expressions, as built into your browser. Most syntax is shared with other languages, but some features — such as possessive quantifiers or certain lookbehind rules — differ in PCRE, Python or .NET.

What do the flags mean?

g = find all matches (not just the first); i = ignore case; m = ^ and $ match at line breaks; s = . also matches line breaks; u = Unicode mode (needed for \p{…} classes and emoji); y = sticky (match only at the current position).

Why did my pattern time out?

Some patterns, such as nested quantifiers like (a+)+, can take exponentially long on certain inputs (“catastrophic backtracking”). The tester runs in a background worker and stops after 1.5 seconds so your browser doesn’t freeze. Simplify the pattern or make it more specific.

Related tools

Validate JSON and pinpoint errors by line and column — including duplicate keys that most parsers ignore.

FreeRuns in your browser

Convert text to UPPERCASE, lowercase, Title Case, Sentence case, camelCase, snake_case and more.

FreeRuns in your browser

Generate random v4 or time-ordered v7 UUIDs in bulk, in the format you need.

FreeRuns in your browser

Pretty-print or minify JSON with your choice of indentation and optional key sorting.

FreeRuns in your browser

Related guides

Guide

A practical regex guide for JavaScript developers

The regular expression syntax you'll actually use in JavaScript — character classes, groups, lookarounds, flags and replacements — with examples you can try.

· 9 min read