I have a string
Best product25.075.0Product29.029.0
And now I need to split this string to
'Best product' '25.0' '75.0' , 'Product' '29.0' '29.0'
How can i achieve this?
You can use re.findall to find all words (containing letter or space - matching pattern [a-zA-Z ]+) or all numbers (one or more digits followd by a dot and zero - matching pattern \d+.0)
string = 'Best product25.075.0Product29.029.0'
import re
re.findall(r'[a-zA-Z ]+|\d+(?:.0)?', string)
# ['Best product', '25.0', '75.0', 'Product', '29.0', '29.0']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With