I am now trying to extract sizes from the string, which is a very common pattern i guess: AxBxC where A, B, C separated with x (may be x with spaces also), are the sizes (int or float):
import re
s = 'zzz 3062 0.2 aaa 15.8x20.2x12.2875 mm'
I am expecting to obtain onli three numbers: [15.8, 20.2, 12.2875] The only working approach i have now is ugly:
r1 = re.findall('(\d+\.?\d*)\ *x\ *', s)
r2 = re.findall('\ *x\ *(\d+\.?\d*)', s)
r1.extend(r2)
print(set(r1))
{'15.8', '20.2', '12.2875'}
Is there any way to use single robust regexp for extraction these numbers? Thanks.