Online text search and replace
Free online search and replace with match highlighting, an occurrence counter, and regex support
Standard JavaScript (RegExp) syntax is supported. The script builds the expression with the g and u flags, and when "Match case" is off, it also adds i.
What works
- Classes and quantifiers: \d, \s, [abc], [^abc], +, *, ?, {2,5}, lazy +?, *?.
- Groups and references: (...), (?:...), (?<name>...), backreference \1.
- Lookahead and lookbehind: (?=...), (?!...), (?<=...), (?<!...).
- Unicode properties: \p{L} (any letter), \p{Lu} (uppercase letter), \p{N} (digit). \p{Cyrillic} does not work, use \p{Script=Cyrillic} instead.
- In the replacement field: $1, $& (the whole match), $<name>, $$ (a dollar sign).
Examples
- All numbers: find \d+.
- Collapse multiple spaces into one: find \s{2,}, replace with a single space.
- Date DD.MM.YYYY to YYYY-MM-DD: find (\d{2})\.(\d{2})\.(\d{4}), replace with $3-$2-$1.
- Same with named groups: find (?<d>\d{2})\.(?<m>\d{2})\.(?<y>\d{4}), replace with $<y>-$<m>-$<d>.
- Links: find https?://\S+.
- E-mail: find [\w.+-]+@[\w-]+\.[\w.-]+.
- Words in capital letters (any language): find \p{Lu}{2,}.
- Repeated word in a row: find (\p{L}+) \1, replace with $1.
- Wrap a match in quotes: find word, replace with "$&".
- The word "cat" but not "catalog": find cat(?!\p{L}).
- Price after the ₽ sign: find (?<=₽)\d+.
- Remove HTML tags: find <[^>]+>, leave the replacement field empty.
Limitations
- \b and \w do not recognize Cyrillic. They work only with Latin letters, digits and _. For Cyrillic text use \p{L} or [а-яё], and for word boundaries use the "Whole word" checkbox (it is built on \p{L}).
- ^ and $ mean the start and end of the entire text, not of a line: there is no m flag. So ^\s+|\s+$ removes spaces only at the edges of the whole text.
- The dot . does not match a line break, and there is no s flag. To match "any character, including line breaks", use [\s\S].
- The u mode is stricter than the default. Unnecessary escaping such as \- or \_ outside a character class causes an "Invalid regular expression" error. Escape only special characters.
- In the replacement field, \n and \t are not interpreted and are inserted as literal characters. The field is single-line, so a line break cannot be entered there. In the search field, \n and \t work.
- $` and $' are not supported in the replacement, nor are flags written in the /abc/gi style: no slashes are needed, enter only the pattern itself.
- Limit: no more than 5000 matches are highlighted.
Quick step-by-step guide: paste your text, enter what to find and what to replace it with, then click "Replace" or "Replace all".
A ready-to-use example with \s{2,}. This is one of the most common requests.
Searching for \n in regex mode will help - replace it with a space.
Your text is never sent anywhere, but if you click "Save text to history", it will be saved to your account and you can delete it later.
Leave feedback about this tool
Comments
Online text replacement helps you find matches that are hard to catch without a dedicated tool. Whether it's text, code, database content, or any other text document, the "search and replace occurrences in text" tool always does the trick!
Additional features include: replacement, match highlighting with match-to-match navigation, support for regular expressions, an ignore-case option, and whole-word search. For convenience, a quick reference of the main regular expressions is provided above, along with a more detailed description of the functionality.