Best answer

Remove item from list that starts with certain characters

  • 31 August 2023
  • 4 replies
  • 157 views

Userlevel 1

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

icon

Best answer by Troy Tessalone 31 August 2023, 17:11

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 +6

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! 😊

Userlevel 7
Badge +14

Hi @Diggity 

Good question.

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

Some guidance:

 

Userlevel 1

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.
 

 

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}];

 

Userlevel 7
Badge +6

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! 😊