Search and Replace Characters in the Clipboard From Paired Arrays

Hi All,

I have been racking my brain for hours on how to perform the following:

  • Copy text from a source
  • Use KM to search and replace specific accented characters if they are found in the system clipboard from a predefined array or dictionary of 16 characters to be replaced
  • Past original text with replaced characters into another app

I have searched the forums and downloaded some macros that give examples of using an array, JSON dictionary, and word pairs, but all to no avail. I can achieve what I want to do with just a single search and replace for a single character, but I thought it would be more efficient to have KM search and replace them all at once, rather than having to create variable for every single character and passing the text text along each time.

Not sure if I'm even making sense, but any help will sure be appreciated.


"Use KM to search and replace specific accented characters if they are found in the system clipboard from a predefined array or dictionary of 16 characters to be replaced"

What are those specific 16 characters or array you refer to ? Can you list them ?

Hi @macdevign_mac, thanks for jumping in!

Here are the characters that I'm looking to replace:

Ά with Ά
Έ with Έ
Ή with Ή
Ί with Ί
Ό with Ό
Ύ with Ύ
Ώ with Ώ
ΐ with ΐ
ά with ά
έ with έ
ή with ή
ί with ί
ΰ with ΰ
ό with ό
ύ with ύ
ώ with ώ

The characters may appear the same depending on the font, but the accent marks are actually different. I did build the following macro (which seems quite inefficient) and I also lose italics and bold formatting as I pass the text to the next variables:

Thanks for being willing to help!



The macro you shown already solves your issue?

Other solutions might be shorter and flexible, but still doing string replacement in a loop.

When you perform string replacement using KM, the formatting is lost, whether using direct string replacement or regex.

Hey @darryl,

Beware of dain brammage – it's all too common these days...

Frustration is sometimes a powerful goad to learn, but don't spin your wheels too long – get some help.

This macro is a trifle more efficient, and it uses the Clipboard for find/replace to leave the text style unaltered.

Replace the items in the Find and Replace arrays as needed.


Find & Replace Characters on the Clipboard.kmmacros (6.7 KB)


Keyboard Maestro Export


@macdevign_mac Yes, I was just trying to figure out a more efficient way of solving my problem.

@ccstone I definitely learned that I need to ask for help sooner! Thanks for taking the time to share your solution! It will certainly help me understand how to use arrays.

Thanks, again!

Hi @ccstone,

Forgive me if I'm being bothersome, but I cannot get this macro to perform correctly. I replaced each of the arrays with the characters I was searching for, but none of them are replaced, and I also lose the text formatting.

The only thing that I've noticed different (apart from the search and replace characters) is the "Execute these actions" number is 1 rather than 16 in your screenshot, but I cannot seem to resolve that. And I'm also unsure why the formatting is not being retained. Could I trouble you for any ideas?



Hey @darryl,

Post your macro, so I can test it.

If we're not testin' we're guessin', and that path is perilous...