I need to break down a string into 3 chunks, (Example: ABC123DEF would end up as X=ABC Y=123 Z=DEF) and need some assistance in getting the alphabetical parts to not be combined into X=ABCDEF as apposed to separate items.
CodePudding user response:
re.split
by \d
and use grouping to keep the splitting-text.
>>> import re
>>> s = 'ABC123DEF'
>>> re.split('(\d )', s)
['ABC', '123', 'DEF']