How to find a number in a string

This few lines will let you find a number in astring.

       Regex re = new Regex(@"\d+");
        Match m = re.Match(txtFindNumber.Text);
      	if (m.Success)
		{
		lblResults.Text = string.Format("RegEx found " + m.Value + " at position " + m.Index.ToString());
		}
		else
		{
		lblResults.Text = "You didn't enter a string containing a number!";
		}


Social:
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • BlogMemes Fr
  • Blogosphere News
  • del.icio.us
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • Reddit

Comments are closed.