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']
"25.075.0"is inherently ambiguous, though. Is it"25.0", "75.0"or"25.07", "5.0"? You need to assume that each number has exactly one place after the decimal point for any of the answers to work. It would be better if you could modify whatever produces that string to use a separating character.