I want to turn a string that looks like this:
ABC12DEF3G56HIJ7
into
12 * ABC
3 * DEF
56 * G
7 * HIJ
I want to construct the correct set of loops using regex matching. The crux of the issue is that the code has to be completely general because I cannot assume how long the [A-Z]
fragments will be, nor how long the [0-9]
fragments will be.
''.join("%s * %s\n" % (n, w) for w, n in re.findall(r'(?i)([a-z]+)(\d+)', input_string))