Insert cursor before word

@gglick Wow, Gabe! That's amazing! :smiley:

I'll download and try that now.

If, however, I needed to keep all the hashtags on one line, can this be easily amended? The guys in charge of the accounts I'm administering prefer to keep all the hashtags on one line (no reason given, but there you are).

I really appreciate you doing this. Hopefully it will work in my version of KB. Because I'm such a lightweight user and barely scratch the surface of what it can do, I've never bothered to upgrade.

Will

Same caveats as gglick with a simpler solution that works for any number of links or hashtags.

It seems all you want to do is put the link (here represented to account for both http and https) and all the hashtags (#) on separate lines from the post. This does that when you copy the text to the variable kmVar.

You would copy a selection in your queue window to the variable and, after processing, paste the result back to your queue window, of course. This is just a demo.

Add Newlines to Post.kmmacros (2.4 KB)

1 Like

@gglick Unfortunately, Gabe, your very excellent solution doesn't work with my installation. I'm not sure why, but will try to trace back through it and see what I find.

Still really appreciate your help.
Will

@mrpasini Thanks, Mike! I'll give that a try and see what I can come up with.

You guys are really generous with your time. It's very much appreciated.

Will

@mrpasini Mike, I just wanted to say I've got your shell script working! :smiley:

Attached is a screenshot of what it worked into my macro looks like. If anyone would like me to post/include the macro itself, please just say.

This is really going to make my job a lot easier. I really do appreciate your and everyone's help on this.

Hope you all have a good evening and a pleasant start to the week.

Will

Bravo! Take the rest of the weekend off :grinning:

You know, I think I will.

I seem to think there is a muffin and a cup of coffee calling my name. :smile:

Best,
Will

2 Likes

This is not a problem for the RegEx I provided you. As you can see below, it handles any number of hashtags:

If you are clicking in the RSS feed box, then your macro above should copy the entire line, regardless of the number of hashtags:

image

So, are you using a different Macro to select the RSS feed? If so, please post it.

I don't believe that you stated before there might be no hashtags. But this is very easy to accommodate:
(.+)\h+(http(?:s?):[^\h]+)(?:\h*(.*))?

For details, see: regex101: build, test, and debug regex

This also captures the RSS feed body prior to the URL, just in case you need that.
It handles any number of hashtags, including none. If there are none, then the Capture Group #3 will return an empty string.

Here is a complete macro, starting with the one that @gglick posted (which should have worked for you). My thanks to @gglick for providing the original macro that I started with.
This is a simple macro which uses the very power native RegEx Search that KM provides, without using any scripts.

Please let us know if this works for you.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change to Your Target App

image

Be sure to change this Action, at the bottom of the Macro, to activate the app where you want the results to be pasted.

Example Output (using BBEdit as Target App)

image

The data and format pasted may easily be adjusted by changing the "Insert Text" Action at the bottom of the Macro:

image

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Extract RSS Feed Body, URL, and Hastags [Example]

**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/c/d/cd2122331ac663de5a9f97ec43d9235e15a71a7f.kmmacros">Extract RSS Feed Body- URL- and Hastags [Example].kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**


---

### ReleaseNotes

Author:  @JMichaelTX based on macro by @gglick

<img src="/uploads/default/original/3X/d/b/dba0d71dc05247a554ef8ab9ba88da6f85d6084e.png" width="604" height="2178">
1 Like

@JMichaelTX Hi, JM.

I posted a screenshot of the solution that I've got working above your reply here. I don't use the forum often, so perhaps I'm not posting things in their best way.

Thanks for your further suggestions. I'll have a look at those as I'm sure they will be useful in future.

Best,
Will

1 Like