How Do I Replace Certain Text in a Block of Text?

I do a newsletter and process text and want to find a shortcut for this particular aspect.

I want to take the included block of text and many similar blocks and perform already existing KM actions on the highlighted words, which will be in the same place in every copy block. The first highlight will be a variable @x and the second block will be simply Tweet.

Would like to simply highlight entire block and have the two actions performed on it.

(BTW, the first action would be to add parentheses and second action to add a link).

It’s not necessary to highlight anything to do that. Try this:

Search and Replace in Tweet.kmmacros (3.8 KB)

06-pty-fs8

Input:

@FSMidwest Bob Gibson on teaching Steve Carlton his slider: "We were on a flight from St. Louis to San Francisco, and he and I spent the entire time on that flight talking about his slider. Then he ended up naving the better slider than me. That didn't make me happy." Tweet.

Output:

(@FSMidwest) Bob Gibson on teaching Steve Carlton his slider: "We were on a flight from St. Louis to San Francisco, and he and I spent the entire time on that flight talking about his slider. Then he ended up naving the better slider than me. That didn't make me happy." Tweet: https://twitter.com/FSMidwest/status/1005514364017922048

Of course, you’ll have to dynamically feed the variables (input text and link to add). But I don’t know what the source for your input texts and links is.

1 Like

@Tom has provided the solution for this.

I hope you don't mind that I have revised your topic title:
FROM: How to create macro for this
TO: How Do I Replace Certain Text in a Block of Text?

in order to better describe your topic contents and help others find your topic.

1 Like

Thanks. I'll play around with this.

Don't mind at all.