I was practicing some regex using re module. I wonder how can we change only some numbers from the string.
a1 = 'images1/b100.png'
# required:
a2 = 'images2/b100.png'
My attempt:
import re
a1 = 'images1/b100.png'
nums = list(map(int, re.findall(r'\d+', a1)))
num0 = nums[0]
a2 = a1.replace(str(num0), str(num0+1))
1to2, but which number do you want to change generally? Is it to always change the first digit to a2? Or add one to the first number? Or change the first number that's before a/to a2? It also would be great if you could show more examples of inputs and your desired output.