Skip to main content
Best answer

Remove item from list that starts with certain characters


Diggity

Hi I have pulled Shopify customer tags as a list into Zapier separated by commas. I would like to remove items from the list that starts with “fbn”. The order of the items in the list will vary per customer along with the number of items in the list.

So for example I have Shopify tags like this:

blue, large, fbn01, hat

With Zapier how can I remove fbn01 by searching the string for fbn.

Thanks

Best answer by Troy TessaloneBest answer by Troy Tessalone

Hi @Diggity 

Good question.

You can use a Code step for this: https://zapier.com/apps/code/help

Some guidance:

 

View original
Did this topic help you find an answer to your question?
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

ken.a
Forum|alt.badge.img+6
  • Zapier Staff
  • 6526 replies
  • August 31, 2023

Hi there @Diggity,

Welcome to the Community! 🎉

You can add a Text in Formatter by Zapier - Replace function to remove the “fbn” data in your tags. The setup will look like this:

56bf2b2785520e33b440add139847f29.png
(view larger)

Here’s the output:

a6d5be74998214974e052a03aa171280.png
(view larger)

Hopefully, this helps! 😊


Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 31362 replies
  • Answer
  • August 31, 2023

Hi @Diggity 

Good question.

You can use a Code step for this: https://zapier.com/apps/code/help

Some guidance:

 


Diggity
  • Author
  • Beginner
  • 1 reply
  • September 2, 2023

Thanks Ken.a and Troy! I was trying to exclude items that contain the string so Ken.a’s method didn’t work for that. But ended up finding Troys article here which worked great.
 

https://community.zapier.com/featured-articles-65/filtering-to-include-exclude-items-in-an-array-using-code-by-zapier-12778

 

So final code is:

let Set = inputData.Set.split(","); // creates array by splitting Input Data Variable at commas

let FilterBy = inputData.FilterBy; // value to filter the array by

Set = Set.filter(i => !i.includes(FilterBy)); // use ! EXCLUDE values in array

output = [{Set}];

 


ken.a
Forum|alt.badge.img+6
  • Zapier Staff
  • 6526 replies
  • September 4, 2023

That’s great news @Diggity! I’m glad to hear Troy’s suggestion worked!

Also, thank you for sharing the code this will be helpful to our other Community members who might run into a similar issue.

If you have any other questions, please don’t hesitate to reach out. We’re always happy to help! 😊