Is it possible to do something like this in Python using regular expressions?
Increment every character that is a number in a string by 1
So input “123ab5” would become “234ab6”
I know I could iterate over the string and manually increment each character if it’s a number, but this seems unpythonic.
note. This is not homework. I’ve simplified my problem down to a level that sounds like a homework exercise.
or:
or:
In any of these cases:
EDIT – the first two map
9to a10, the last one wraps it to0. To wrap the first two into zero, you will have to replacestr(int(x) + 1)withstr((int(x) + 1) % 10)