Looking for exact numbers in list

dynamo

#1

how I get only the exact matching nummers from the list? now i get the number 254 and 255 too. but i only want the numbers 54 and 55

Capture


#2

Maybe add an equal node to it?

Have no computer arround here so can’t test it


#3

As vanlion says, use the == node :slight_smile:

You can try something like this:


#4

Also, those are strings not numbers. Converting tour data to the correct type will save you some headaches.


#5

I think that the issue presented here by @royboverhoff is that he would like to get only parts of a string but the logic used in “string.contains” is that 254 contain 54 etc. so in order to solve your problem Roy you’d have to look at the length of the string or even better work with numbers if this is in fact what the stringlist is.

It would be nice to see what your stringlist contain as it is not element id’s as a lot of your “in” outputs of boolmask does not contain either 54 or 55.


#6

You could try, starts with instead of trying to get the entire strings?

That is unless there are not number like 540 or 550!!!


#7

Why not filter out the numbers based on the length to start with?


#8

Try this in a code block :wink:

input==54 ?
true:
input==55 ?
true:
false;
image

or for a string

input==“54” ?
true:
input==“55” ?
true:
false;


#9

I think @Ewan_Opie has both the easiest and most elegant solution here.


#10

its same


#11

Personal preference is designscript for simplicity, but OOTB is perfectly capable, nice one @til.shviger :grinning: