Filter out elements with string contains

Hi there, I’m new to Dynamo, and trying to filter out elements (familytypes). I’ve created an excelsheet with the types it needs to filter, I’m using the node: string contains. However, it doesn’t filter correctly.

It’s only filtering E001 and E005. But it’s missing E002, E003 and E004. What am I missing here? I hope someone can help me out here.

@tomwijnholt check this out:

@Elie.Trad

Thanks for the quick response.
However I dont need to replace anything. I just want to filter out 5 elements (E001, E002, E003, E004, E005) out of my element list.

Is there another node from clockwork that does the trick?

Hello…here is a few options, hope its what you want…

Look into List Levels. You need to search for each substring recursively. Right now you’re using Longest lacing and that’s why it’s “skipping” some inputs.

If you’re looking for exact matches you could also write a nested conditional (If) statement to check for each substring concurrently.

1 Like

yeps @Nick_Boyts …think you are right havent seen the levels :wink: and many ways to do it :wink:

Hi @tomwijnholt ,

You want to check for each item in your list if it contains any of the “SearchFor” inputs.
You will have to set the String.Contains node to cross-lacing for that, this means every item in the first list gets matched against every item in the other list, this is exactly what we want right now.

However we now end up with a list of true/false which is 5 items long, 1 true/ false per “SearchFor” string.contains result, since we want to return true if any one of the five items is true we can simply use the node List.AnyTrue with a list level set to 2:

PS: A100 is also included in the last list since it includes “A10”, when you want exact matches replace the String.Contains node with a == node also set to cross-lacing :slight_smile:

HI @Daan

Thanks this is great, it works now. Thanks a lot!

@Nick_Boyts I’ve got it working now, thanks a lot!