Extracting numbers from string

This seems simple, yet I’m struggling

I have:
underscore12underscore
M10
GR2
23AF

I need:
12
10
2
23

7 Likes

Another option:

output = []
for x in IN[0]:
    output.append(float(filter(str.isdigit, x)))
OUT = output

This can of course be used in a “closed” python node as well:
image

7 Likes

I’m too slow with typing … lolz. But this is basicly the same as @Andreas_Dieckmann does using the useful clockwork package nodes
Capture

Script

import re

strings = IN[0]

output = []
for str in strings:
	matches = re.findall('\d+', str)
	output.append(matches)

OUT = output
5 Likes

Brilliant, thank you all very much!

Can also do this OOTB


… or a nested line of Design Script to avoid the error message

String.Concat(List.Clean(String.ToNumber(String.Split(s,"")),false)+"");

8 Likes

How do I get the decimals and digits in this?

Have this…
image
after…
image

String.Replace(strings, “Level “, “”);

1 Like

Using @Andreas_Dieckmann’s model, just add a period within the regex string:

3 Likes

Need something that will remove any letters and leave the numbers and decimals, thanks Kenny n Jacob

Thanks for your responde

How do modify your code if you have a float number? i.e 12.5

Regards

1 Like

use @Andreas_Dieckmann and @kennyb6 's model