Best answer

How to remove all hashtags before posting to Twitter?

  • 24 August 2021
  • 4 replies
  • 273 views

Userlevel 1

Hello,

I thought I figured this out using regex, but it didn’t work.

I’m posting from Instagram to Twitter and I want to remove all hashtags.

My second step in my Zap was using the Formatter action with this regex: (?<!#)\b\w+

It captures everything except all the hashtags (great!) except not so great… because it returns all matches (everything that’s not a hashtag) as line items. 

So in my Twitter step, I could have a list of like 50 options (one word per match) making it impossible to choose all for the caption.

There has to be a better way to do this and I’m sure I’m not the first to ask for this! Any help would be greatly appreciated!

Thanks,

WDES

icon

Best answer by Troy Tessalone 25 August 2021, 03:21

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 7
Badge +14

Hi @WDES2021 

Can you post a screenshot of some example text that you are trying to parse/format?

Userlevel 1

Of course:

 

And here is the output (notice one match per word):

 

 

And the problem:

 

Notice the Output # matches the position of where that word is, due to the match.

Appreciate the interest! Any help would be greatly appreciated,

WDES

Userlevel 7
Badge +14

@WDES2021 

If the hashtags are always at the end then just split at the first # and keep the first segment.

Action: Formatter > Text > Split: https://zapier.com/help/doc/how-use-formatter-functions#using-split-text

Userlevel 1

I tend to overthink things… and was trying to come up with a solution for a situation where I’d have a hashtag somewhere in the middle. Realistically I don’t think that will happen, so I’ll just do it the way you mentioned and avoid myself an unnecessary headache. BTW, @Troy Tessalone  - Thanks for the quick reply!


WDES