Issue
I have a set of strings that I would like to split into smaller blocks.
The string is in the format:
60I40J10=14X240P432;
How can I use python to split the string into:
60I 40J 10= 14X 240P 432;
Thank you for your help!
Solution
Try this:
>>> st = '60I40J10=14X240P432;'
>>> fnd = re.split('(\d+)',st)[1:]
>>> list(map(''.join, zip(fnd[::2],fnd[1::2])))
['60I', '40J', '10=', '14X', '240P', '432;']
>>> print(*map(''.join, zip(fnd[::2],fnd[1::2])))
60I 40J 10= 14X 240P 432;
Answered By - user1740577
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.