Given an input string containing only alphanumeric ASCII characters and starting with a letter, swap each letter run with the digit run which follows.
A run is a sequence of consecutive letters or digits. Note that in the case where the input string ends with a run of letters, this run is left untouched.
Walk-through example
For instance, given the input string uV5Pt3I0
:
- Separate runs of letters and runs of digits:
uV 5 Pt 3 I 0
- Identify pairs of runs:
(uV 5) (Pt 3) (I 0)
- Swap pairs of runs:
(5 uV) (3 Pt) (0 I)
- Concatenate:
5uV3Pt0I
Examples
uV5Pt3I0 -> 5uV3Pt0I
J0i0m8 -> 0J0i8m
abc256 -> 256abc
Hennebont56Fr -> 56HennebontFr
Em5sA55Ve777Rien -> 5Em55sA777VeRien
nOoP -> nOoP
This is code-golf so the shortest answer in bytes wins. Explanations are encouraged.