Replace Strings in Input Box via Tab-Del Glossary

This macro copies the whole content of an input box to the clipboard. It then reads the lines of a tab-delimited file (a ‘glossary’) and performs a Search and Replace System Clipboard action for every line of the file, using the first and second column of every line as Find and Replace string respectively, and the third column to set the 'kind of search to run' (search type). When all lines in the glossary are handled, the macro pasts the content of the clipboard to the input box.

Though this macro has been developed for a specific purpose and a specific app (CafeTran Espresso), it contains some techniques that you might want to use for your own purposes.

The glossary file should have the following structure:

red\tgreen(\tsearchType)

Where searchType would be:

  1. sc for case sensitive searching of a string
  2. si for case insensitive searching of a string
  3. rc for case sensitive searching of a regular expression
  4. ri for case insensitive searching of a regular expression
  5. wc for case sensitive searching of a word
  6. wi for case insensitive searching of a word
  7. wa for case adaptive searching of a word
  8. wt for toggling the case of a word
  9. ‘ ’ (empty) when the third column is left empty, the macro defaults to ‘wc’; this way, normal glossaries (with only two tab-delimited columns) can be used.

1
Replace strings in Target Segment Editor via tab-del glossary.kmmacros (36.8 KB)

1 Like

The macro image in a separate message, for better legibility.

Hi, @ALYB. Very creative. Thanks for sharing.