⬅︎ Back to "Increment numbers in a string"
Looks to big for me... this will also workimport redef increment(s):....re.sub(r'\d+(?=[^\d]*$)', lambda m: str(int(m.group())+1).zfill(len(m.group())), s)It's also faster. If you think it's too complex you can break it up.
Comment
Looks to big for me... this will also work
import re
def increment(s):
....re.sub(r'\d+(?=[^\d]*$)', lambda m: str(int(m.group())+1).zfill(len(m.group())), s)
It's also faster. If you think it's too complex you can break it up.