Regex Find and Replace

Find and replace text with a regular expression, and see every match with its line number.

How to use

What it checks and how it works

The tool runs JavaScript's own regular expression engine, as documented on MDN, and applies String.replace with your replacement pattern. Unicode mode is on by default so that Arabic letters and emoji count as single characters. The match table lists up to 200 matches with their line numbers and capture groups. Plain text mode escapes your pattern so symbols such as . and ( are matched literally. JavaScript syntax differs from PCRE and Python: there are no possessive quantifiers or inline comments, and lookbehind support depends on your browser. A pattern that repeats a repeated group, such as (a+)+, can make the page slow on some text, so the tool warns about that shape. Input is limited to 500,000 characters.

How do I reuse part of a match in the replacement?

Wrap the part in parentheses and write $1 for group one, $2 for group two, and $& for the whole match.

Why does my pattern work in another tool but not here?

This tool uses JavaScript's regular expression syntax, which differs from PCRE, Python and other flavors. Named groups and lookahead work, but possessive quantifiers and inline comments do not.

Can I match Arabic letters?

Yes. Keep Unicode mode on and use a range such as [\u0621-\u064A], or the property escape \p{Script=Arabic}, which needs the u flag.

Sources

Related tools

Privacy

Runs in your browser; nothing is uploaded. The interactive tool needs JavaScript.