Random search and replace

Hi!,

Is there anyway to run a macro that will replace whatever is between HTML title tags? If it was going to be the same text every time I could just use a simple search and replace but because it will be different each time the only way I know would not work...

So KM would search the text within a file named tour.html and look for the opening and closing title tags. It would replace any text within the tags with whatever is currently on the clipboard. So for example if 123 High Street was on the clipboard then KM do this:

Find this text within the HTML file: <title>krpano - utiltiyroom</title>

And replace it with this: <title>123 High Street</title>

I am sure there is a way of doing this but after numerous searches I cannot seem to find anything that will do this?

Thank you in advance for any help.

The Search and Replace action and RegEx should work for this. See my sample macro below. ↓

Download Macro(s): Replace HTML title tag contents.kmmacros (2.0 KB)

Macro-Image

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
  • The user must ensure the macro is enabled.
  • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 13.6.3
  • Keyboard Maestro v11.0.2
4 Likes

This worked perfectly. Thank you so much for your help :smile:

1 Like