How to filter a list by using the first four characters

First, let me start off by saying that I wanted to search for a posting like this, but I didn’t exactly know what I was searching for. So if this is a duplicate post, my apologies. Also, due to company policy, I cannot share any content from the project. If such content is required, I will need to re-create a fictitious scenario.

Let’s say I have a long sheet number, as most large projects do, and is similar to this:

AB##.####.####

I want to cut down on the scrolling to select a specific sheet in a long list, over 1000. What method would I use to filter all the sheets down to a much more usable list by filtering from the first four digits?

AB##.####.####

It seems like a simple thing, but I am stumbling with it. Any help is much appreciated.

String.Substring to take subset of characters. Then do the comparison test - perhaps == to the characters you are trying to filter to, and then filter the sheets by those boolean values with a List.afolterByBoolean mask.

If the subset you are working with is always the initial portion of the string you can also use the Sting.StartsWith node which will feed directly into the mask portion of the filter by booleans mask node.

As Jacob said, you could do this providing your prefix is always consistent with String.StartsWith.

If it’s not a prefix, you go his second example of String.Contains.

1 Like

Apologies for not responding sooner. A lot going on. I really need to work with the lists more as it’s probably the one thing I need to know most that I keep trying skirt. I will try the suggestions from you both, but it looks like you guys pointed me in the right direction. Thank you.

1 Like