belun.app Blog
RU

Find and Replace Text Online: Regex, Whole Words, and Case

How to run a bulk find and replace in the browser — capture groups, the word-boundary trap that breaks non-English text, and keeping capitalisation intact.

Hands typing on a laptop keyboard while editing a document, find and replace text online

Last spring I renamed a product across about 340 lines of marketing copy. Easy job. Search “Beacon”, replace with “Halo”, done in four seconds.

Then I read the result. “Beacons” had become “Halos”, fine, but “Beaconsfield Road” in a customer address had turned into “Halosfield Road”. And every sentence that used to open with “Beacon” now opened with a lowercase “halo”, because I’d typed the replacement in lowercase and the tool took me literally.

That’s find and replace in one paragraph. The searching part is trivial. Everything interesting lives in the three checkboxes next to it, which is why the Find and Replace Text tool puts them right under the input rather than behind an “advanced” link.

Whole word is harder than it looks

Turning on whole-word matching would have saved Beaconsfield Road. But there’s a catch that bites anyone working outside English, and most online tools walk straight into it.

The usual implementation wraps your search term in \b, the regex word-boundary anchor. In JavaScript, \b is defined in terms of \w, and \w means exactly [A-Za-z0-9_]. Nothing else. Not é, not ß, not a single Cyrillic letter.

So search for кот with whole-word on in a \b-based tool, and it happily matches inside котёнок, because as far as the regex engine is concerned the ё right after your match isn’t a letter at all. Same story with café and cafés in French, or any German word ending in ü.

This tool skips \b and checks the characters either side of the match against the full Unicode letter and number categories. Cyrillic, Greek, Vietnamese, accented Latin: all bound the way a human reader would expect.

Capture groups turn replacing into reformatting

Tick Regex and the replacement field starts understanding $1, $2, and $<name>. This is where a find and replace stops being a rename and starts being a data transform.

A few that earn their keep:

  • (\w+), (\w+) replaced with $2 $1 flips a whole column of Smith, John into John Smith
  • (\d{4})-(\d{2})-(\d{2}) replaced with $3/$2/$1 converts ISO dates to the format your spreadsheet actually accepts
  • \n{2,} replaced with a single space collapses the blank-line mess you get pasting out of a PDF

Anchors run per line here, so ^ means the start of every line, not the start of the whole document. Prefixing 200 URLs with a domain is ^ replaced with https://example.com.

With Regex off, the replacement is completely literal. A $1 you type stays a $1, which matters if you’re editing pricing copy.

Match case of original

The setting that would have fixed my lowercase sentence starts, and the one most tools don’t have at all.

Case sensitive and Match case of original sound like the same thing and do opposite jobs. The first decides what counts as a hit. The second decides what gets written back: replace color with colour and COLOR becomes COLOUR, Color becomes Colour, color stays colour. Three capitalisations, one pass, no cleanup afterwards.

It never leaves the tab

The replacement runs in JavaScript, in your browser. No upload, no queue, no log line with your text in it. Load the page, kill your wifi, keep working.

Worth caring about, given what people actually paste into these boxes. Database exports. Contracts with names in them. Server logs with internal hostnames all over them.

Open Find and Replace Text, paste your text, and watch the match counter before you trust the result.

Try the tool

Find and Replace Text →