0

How to get last numbers in a string. If numbers aren’t allows one or two digits.

250-HP-1403-CCT1. Needing 1 250-HP-1403-CCT10. Needing 10

13th Feb 2021, 8:21 AM
Corey
5 Antworten
+ 4
Please specify the programming language and use the tags appropriately. And show us what you've done so far. To get the Last Number on a String: You can first reverse the string then use 'for loop' to iterate then if the next character is not a number then break the loop then reverse again the output number. Or you can use regex and find the group of numbers then get the last number.
13th Feb 2021, 8:31 AM
noteve
noteve - avatar
+ 2
//python print(int(str[::-1])) //ruby puts str.reverse.to_i
13th Feb 2021, 8:25 AM
TOLUENE
TOLUENE - avatar
0
i feel im wasting peoples time with my entry level qeustions. im such a rookie. whats the purpose of the tag number.?
13th Feb 2021, 9:15 AM
Corey
0
ohh and its SQL..
13th Feb 2021, 9:17 AM
Corey
0
Right([SerialNumber],InStr(1,[SerialNumber],"CCT")-1
13th Feb 2021, 9:20 AM
Corey