I have some strings which are dynamically created at run time.
The values are generated in sequence with an underscore, leading zeroes and then the sequence number. The format looks like so:
_00001
_00002
_00003
_00004
_00098
_00099
_00100
_00101
I would like to extract the number part as Integer, ignoring the underscore and leading zeroes.
StringReplace can easily remove the underscore part, but how can I extract the number part as I have no way of knowing what the values are?
Some example outputs of how such a function would work:
_00003 = 3
_00098 = 98
_00482 = 482
_07218 = 7218
_14005 = 14005
_37585 = 37585
_69732 = 69732
StringReplace and Pos is what I am thinking, but I am not always sure as to how to fully use Pos, and the StringReplace method could possibly be messy.
I think all I need to do is check for the first number that is not 0, but maybe I am confusing myself again so really any pointers are welcome.
StrToInt(Copy(S, 2, MaxInt))