I have used a macro for a long time that takes whatever text is highlighted, searches and replaces the linebreaks with the > character, for quotation purposes in apps like ZenDesk etc.
However, having upgraded to KM9, this no longer works as expected. I'm not entirely sure why, and I haven't been able to find an updated replacement. Could somebody advise/assist?
Since I don't have KM v8 any more, I can't figure out what your macro is supposed to do because you said your macro doesn't work in v9. The only way I can figure out what your macro is supposed to do is to read the text in your post. And all I see in the post is "replace line breaks with > character". but I think that's not all you want to do because your macro looks much more sophisticated than that.
If you are willing to explain in the post exactly what you are trying to do, I can help. I enjoy text processing problems.
If all you are trying to do is replace line breaks with > that's easy:
With a bit of investigation, it seems like I need to figure out/use a sed command, which I haven't used before. Will dig in a bit and see if I can get that working, unless someone can point me the right way!
**Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/f/e/fea597a60bbd299be2c1500d498a8e325c0563ba.kmmacros">TEST Regex Replace Syntax.kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
<img src="/uploads/default/original/3X/f/f/ff44533135e1349ade7524da1cc92f577f016ee4.png" width="528" height="703">
Thanks! I enabled this and tried it out but it didn't seem to do anything. I had the same issue when trying Search and Replace earlier today. Not sure what the deal is there.
Does anything stand out as obviously wrong there? The idea is to be able to highlight a paragraph, hit the hotkey and then have the text replaced with the > on each line.
I just came back from dinner. Your solution looks quite efficient. It should be fine. But I recommend trying to get JM's solution to work because it probably uses less macOS resources. I'll leave it between the two of you because he's an elite wizard and it's his macro.
The reason the macro does not work is that it is using $2 in search & replace cases where there is no second capture group. I'd guess that in previous versions, that is probably just returning an empty string, but it was never legitimate.
All you should need for this conversion is this Search & Replace:
(although I just noticed that is leaving the result as rich text even if the source was only plain text, which I will resolve).
The OP post macro. “having upgraded to KM9, this no longer works as expected” - because it should never have worked as expected (I'm not really sure what the $2 would event be intending to mean in a regex with only one capture).
Thanks for all the help. I have no idea what the original macro's logic was... I set it up years ago and forgot about it, so your guess was as good as mine. I am not really a skilled scripter/programmer, so I just muddle through until it works.