80 x 59 x 53 108 x 98 x 73
I want to split this string into
80 x 59 x 53 and 108 x 98 x 73
There could be any number of spaces in between any characters
Please help me to solve this
Thanks in Advance
80 x 59 x 53 108 x 98 x 73
I want to split this string into
80 x 59 x 53 and 108 x 98 x 73
There could be any number of spaces in between any characters
Please help me to solve this
Thanks in Advance
Use positive lookbehind and positive lookahead regex
:
import re
s = '80 x 59 x 53 108 x 98 x 73'
print(re.split(r'(?<=\d)\s+(?=\d)', s))
# ['80 x 59 x 53', '108 x 98 x 73']
If you're concerned about and
in-between:
print(' and '.join(re.split(r'(?<=\d)\s+(?=\d)', s)))
# 80 x 59 x 53 and 108 x 98 x 73