KeyRoutines
StepFreetext.replace

Find and replace text automatically in a Windows routine

Replace text finds every occurrence of something in a text and swaps it for something else, or removes it. It works on clipboard text, file contents and step results alike.

How it works

  • Set the text, what to find and what to put in its place; leave the replacement empty to delete it.
  • Match case is on by default; turn it off to replace regardless of upper and lower case.
  • Turn on the advanced pattern option to use a regular expression, where $1 puts a matched group back.
  • Without the pattern option, symbols like $ are treated as plain text.

Routines that use it

Strip tracking

Get a link from the clipboard, remove a tracking part with a pattern and set it back with Set clipboard.

Fix file names

Replace spaces with dashes before Rename file.

Edit a text file

Read a file with Read text file, replace an old path and save it with Write text file.

Settings

SettingWhat it does
TextThe text to change.
FindWhat to look for.
WithWhat to put in its place. Keep empty to remove it.
Match caseOnly replace text with the same upper and lower case.
PatternadvancedTreat Find as a regular expression; $1 in With puts a group back.

Good to know

  • Pattern searches are limited to 100 milliseconds each.

Questions

Can I find and replace clipboard text with a hotkey?
Yes. Use Get clipboard, Replace text, then Set clipboard in a Hotkey routine.
How do I remove a word from text?
Put the word in Find and leave With empty.

Pairs well with

Build this routine in KeyRoutines

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.