know if first letter is a letter or a number?

  • Thread starter Thread starter trint
  • Start date Start date
T

trint

I need to know if this string, which will always vary is a letter or a
number value AND if it is a letter, to only get the number, which is
obviously 7000:

string prodID = "us7000";

is Parse, the best way to get this?

Thanks,
Trinity
 
Hi,

You can use a RegExp to split the string to the textual and the numeric
part, and then apply int.Parse to the match for the numeric part.
The RegExp will look like this:

([a-zA-Z]?)([0-9]+)
 
Back
Top