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]+)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top