How to keep only numbers with space in between them using regex?

2870 views regex
0

I have a column with rows contains as follows:

"95ML GRATUIT 250+95ML GRATUIT"

"95ML GRAT 500ML"

"500ML +250ML"

So these rows contain numbers with measurement in "ML" so I want to make a new column which contains only numbers. For example:

95 250 95

95 500

500 250

I want the above output in my column.

answered question

[\d ] this should work

@advay.umare Hi thank You for the quick response but its not giving me the ouput which i want

1 Answer

2

python 3:

import re
data = "95ML GRATUIT 250+95ML GRATUIT" "95ML GRAT 500ML" "500ML +250ML"
final = ' '.join([x for x in re.findall('/d+',data)])
print (final)

posted this

Have an answer?

JD

Please login first before posting an answer.