Character classes
. any character \d digit 0-9 \w letter, digit, _ \s whitespace [a-z] character range [^x] anything except listed $1 … $9 for capture groups, $& for the whole match and $<name> for named groups. Cards load a pattern, flags, test text and replacement into the tool.
Common JavaScript RegExp syntax at a glance.
. any character \d digit 0-9 \w letter, digit, _ \s whitespace [a-z] character range [^x] anything except listed ^ start of string or line $ end of string or line \b word boundary \B not a word boundary * 0 or more + 1 or more ? 0 or 1 {n,m} from n to m *? lazy quantifier (...) capturing group (?:...) non-capturing group (?<n>...) named group a|b alternative (?=...) lookahead 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.
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.
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.
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.
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.
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.
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.
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.