Regexp Online - test, debug, search and replace

Regular expression flags

Test text

0 characters

Replace text

Use $1$9 for capture groups, $& for the whole match and $<name> for named groups.
Enter a pattern and text to see the result.
Match highlights

Ready-made examples

Cards load a pattern, flags, test text and replacement into the tool.

Regex cheatsheet

Common JavaScript RegExp syntax at a glance.

Character classes

. any character
\d digit 0-9
\w letter, digit, _
\s whitespace
[a-z] character range
[^x] anything except listed

Anchors and boundaries

^ start of string or line
$ end of string or line
\b word boundary
\B not a word boundary

Quantifiers

* 0 or more
+ 1 or more
? 0 or 1
{n,m} from n to m
*? lazy quantifier

Groups and logic

(...) capturing group
(?:...) non-capturing group
(?<n>...) named group
a|b alternative
(?=...) lookahead

FAQ

Regex is the common short name for a regular expression. RegExp is the built-in JavaScript object that runs regular expressions in the browser. This tool tests patterns as JavaScript RegExp.

Enter a pattern without surrounding slashes, choose the flags you need, and paste test text. Matches are highlighted automatically and listed with index, position, length and capture groups.

Turn on the g flag and fill in the replacement field. Without g, JavaScript replaces only the first match; with g, it replaces every match. The final text appears in the Replace tab.

The g flag means global: matching continues after the first found fragment. Use it when you want the full match list or want replacement to affect the whole text.

$1, $2 and other numbers insert numbered capture groups, $& inserts the whole match, and $<name> inserts a named group such as (?<name>...). Use $$ to insert a literal dollar sign.

No. The pattern, source text, replacement string and matches are processed locally in your browser.

JavaScript, Python, PHP, PCRE and Java differ in flags, lookbehind support, Unicode mode, escaping and specific syntax features. This tool follows JavaScript RegExp rules.

Online regex tester for JavaScript RegExp

regexp.online helps you test and debug regular expressions in the browser. Enter a pattern, paste sample text, review highlighted matches, inspect capture groups, and try a replacement without sending your text to a server.

Regex and RegExp

A regex is a pattern for finding, extracting or replacing parts of text. In JavaScript, regex patterns are executed by the RegExp object, so this tester follows JavaScript syntax and behavior.

How to use the tester

Type the pattern without the surrounding slashes, choose the flags you need, and add the text you want to check. The result updates automatically with match indexes, ranges and capture group values.

Matches, groups and replacement

The Matches tab shows every found fragment and its position in the source text. The Replace tab applies JavaScript replacement syntax, including $1, $2, $& and $<name> for named groups.

JavaScript RegExp flags

Use g to find all matches, i to ignore case, m for multiline anchors, s so the dot also matches line breaks, and u for Unicode-aware matching.

Common use cases

Regular expressions are useful for finding emails, phone numbers, URLs, dates, numbers, repeated whitespace and markers in logs. The ready-made examples above can be loaded in one click and adjusted for your own text.

Things to watch for

Common mistakes include unclosed brackets, missing escaping, forgetting the g flag, expecting PCRE-only syntax, or using a pattern that is too broad, such as .*. The error message in the tool explains why a pattern failed to compile.