Search for letters in a string

Hey guys, I’m looking to be able to filter (like true or false) a list if it has a letter in it.

What I’m trying to achieve:
I am going to replace all the Mark Values with Element ID. I got that script to work no problem.

Issue is, before i can apply this script i have to search the Mark Values and make sure no one has put a “comment” in it. Typically it is something like “Panel xyz needs to be connected to wrx”. In any case, it could be a mix of letters and numbers. Since the Mark Value should ONLY contain numbers, i want to be able to filter all my marks by separating the ones that have this potential comment in there.

I tried different methods. I just do not think i have my head around a way to filter by letters. Here is what i have done (I’ve tried different approaches but don’t have it on this clip)

Let me know if there is a node, method or even a thread i can look in.

I highly appreciate your time and help and am learning every time i come here. Thank you for your time.

Use cross product instead of @L1 for the String.Contains node. This will give you sublists of n string checks based on your n-sized alphabet.

You can count the number of ‘true’ hits in the sublists at this point to determine how many letters exist.

2 Likes

I like this solution Comparing two lists and getting the index of the "matching pairs" - #3 by AmolShah

3 Likes

How long are the marks? if they vary project to project, you could ask for user input at the start, flag and that are more than 1 more or less than the user input. Or like create a default when a new project is created that the script can reference. Standard element IDs are like 6-7, right?

Could also just look for spaces.

If your users aren’t picky about seeing errors, you could try String.ToNumber, clean w/ preserve, filter

1 Like

well, that seems to do it. unreal, AmolShah, helped me with a previous question i had that i didn’t think this would apply to. i will make sure from now on to attempt anything i was taught before trying to reinvent the wheel.

Now if i want to be able to select said elements that are “true” in the project to make sure i do not overwrite them and give time for the designer to copy his “comment” elsewhere.

This also worked, but the solution set by @Drbohlav seems to be more elegant and simpler. Thank you very much for your help and input.

@DaftPooch Try this:

I’ve removed your dependency on packages and also made sure that capital start letters are also covered in the check.

Also, you don’t need to type in a through z in the code block you can simply use
“A”…“Z” or “a”…“z” or “A”…“z”

Just use the same boolean mask to filter the elements as well.

2 Likes

holy guacamole @AmolShah thank you for your prompt help!! that’s absolutely awesome. I will try this out right now!

1 Like