I have a string, and i need to check whether it contains a number/digit at the end
of the string, and need to increment that number/digit
at the end of the string with +1
I will get the strings as below
string2 = suppose_name_1
string3 = suppose_name_22
string4 = supp22ose45_na56me_45
for sure i will get the string in the above format like suppose_somthing + Underscore
+ digits
So from the above strings
- I need to check whether a string contains a number/digit at the end of the string after underscore
If it contains then need to increment that with
+1
like belowstring2 = suppose_name_2
string3 = suppose_name_23
string4 = supp22ose45_na56me_46
How can we do this in python by using regular expressions or something, but that should be very fast.
I have done something like here, but want to implement with re that will be very fast , so approached SO
Edit:
sorry din't mentioned above
Sometimes it contains just something_name
without integer, hence i need to check whether it contains a number in it first