Best answer

Using formatter to replace all words beginning with a particular character

  • 26 September 2020
  • 4 replies
  • 1861 views

Userlevel 1

Hello!

I’d like to use the Formatted function to remove all the words that start with a “#” from a text field.

These can be of different lengths etc and can be replaced with a single space.

Can this be achieved?

Many thanks!

 

Matthew

icon

Best answer by Danvers 28 September 2020, 13:33

View original

4 replies

Userlevel 7
Badge +12

Hmm, this is a tricky one. I think that whether or not it will be possible depends on if there will be more than one word that starts with a # in the text field. 

 

It sounds like you need to replace more than one word in the field, is that right? If there’s more than one word that starts with a # in the text field, then I don’t think that this would be possible using the Formatter. 

 

If there’s just one word per text field, then I think that this is possible using the following steps:

  1. Formatter > Text > Extract pattern - use regex to find the word that starts with # (this will only give you the first word that it finds that matches the expression)
  2. Formatter > Text > Replace - use the output of the Extract pattern step to tell the Zap which word to replace with a space 

Hmm, this is a tricky one. I think that whether or not it will be possible depends on if there will be more than one word that starts with a # in the text field. 

 

It sounds like you need to replace more than one word in the field, is that right? If there’s more than one word that starts with a # in the text field, then I don’t think that this would be possible using the Formatter. 

 

If there’s just one word per text field, then I think that this is possible using the following steps:

  1. Formatter > Text > Extract pattern - use regex to find the word that starts with # (this will only give you the first word that it finds that matches the expression)
  2. Formatter > Text > Replace - use the output of the Extract pattern step to tell the Zap which word to replace with a space 

Hey, can you tell me what the regex expression would look like? I am trying to replace all text after “-” in a single text string. Thanks a lot!

Very strange.
Why wouldn’t it be able to find each word that has a #. Seems like basic functionality.

Userlevel 7
Badge +11

Hi there folks! 👋

@Omna - I expect you’ve already got this figured out but I just came across this and wanted to suggest checking out this guide where you can learn more about using regex to extract certain types of information here: 


@Swordfish - The Formatter (Text > Extract Pattern) action has since been updated and has an option to allow it to return all matches, not just the first match:
fb49b5729829d62f531fa98e0b2b60a3.png

If you run into any issues on using that Formatter action please do let us know. Happy to help further! 🙂

Reply