Remove characters of items

Hi everyone,
Can anyone tell me how to remove some characters of string?
For example, I have an item “thickness default 150mm” and I’d like to remain 150 for calculation in next steps.
Thank you in advance

Hi Hoc_Em,

What about regular expression?

There are multiple ways to do this. Regular expressions, as Einar stated, may be the most robust way, but if the data is consistent you can try something like this also:

Here is another OOTB way, if the number alwas is last and has mm as unit

This might work too…

1 Like

My last response doesn’t address the original problem.
This should (provided there is only one number in the string)…

Could use code to avoid the error thrown when nodes are used

s1=String.Split(str1,{""," "});

I overlooked the multiple separator option in Sting.Split. (Thank you Vikram, I don’t think you need it though). Here is a solution that extracts all number in the string, if you add the units to string split. Maybe a clean node would be better than RemoveIfNot.

Got it! Thank you for your help!

1 Like

And one more (basically it’s the same as Clockwork node)


@Tomasz_Puchala’s solution seems to be the most efficient one!

Hi Guys,

I am trying to shorten file name that are coming from revit. So far I am trying to find the best way to pull apart the file name, remove a few words in the string and stitch it back together. I am not sure of the best way to do this but it seems like @Tomasz_Puchala was close with his custom python node. Right now I have successfully isolated the pieces of the file name I would like to preserve but am losing the 's because I have used them as identifiers to tell dynamo where to break up the list. Can anyone help me with this?

@kloffredo Please start a new topic and post what you have done so far.

Hi Guys,

@Tomasz_Puchala Python script works great for a list of strings. But how to make it work for a list of lists with strings? an @L3 list? or just make it work no matters the dimension of the list?

Thank you.

Hello all,

How do I delete the value " and extract the float number?

I am trying to extract the float number i.e: 16.2 from first value on the list below: