Action to put # in front of every word in draft

Looking to create an action to put # in front of every word in draft - so I can quickly create hashtags when posting on Instagram. Trying playing with regular expressions and replacing but can’t get it to work.

Anyone able to help?

Thanks!

Try this action:

It uses a regular expression based replace that is using a word boundary and word pattern for the match and then prepends the hash. After that the draft is simply updated.

draft.content = draft.content.replace(/(\b\w)/g, "#$1");
draft.update();

Hope that helps.

1 Like

Works perfectly! Thanks so much!