Hello all,
I am working with a Tcl script and have some strings in the following format (RE):
[a-zA-Z]+[0-9]{6}-[0-9]
There are some leading letters, combinations of capital and lowercase. Then six digits, followed by a hyphen, then one more digit.
I would like to remove all of the leading alphabetic characters from the string. The resulting string would then be in this format: [0-9]{6}-[0-9]. In other words, six numeric digits, a hyphen, then one more digit.
I have tried:
Code:
set newstr [string trimleft $origstr alpha]
But that only removes the
first alphabetic character, not
all of them.
I couldn't get anything with regsub to work correctly, but I am somewhat of a noob with RE's in general and regsub in particular.
There are
usually 5 leading letters at the beginning of these strings, and I could in most cases get away with using
string replace and constant indices to extract the substring.
However, my preference is for this to be robust enough to handle all cases with 1 through n leading alphabetic characters.