I am trying to solve a problem which says, to add 1 at the end of a string. Which means:
1.abcd12 will become: abcd13
2.abcd099 will become abcd100
3.abcd01 will become abcd02
4.ddh^add@2204 will become ddh^add@2205
My code:
import re
def increment_string(strng):
regex = re.compile(r'[0-9]')
match = regex.findall(strng)
nums = ''.join(match[-3:])
add = int(nums)+1
print(strng+str(add))
increment_string("abcd99")
The code gives me this Output: abcd099100 and I don't know how to solve it: