Pages

Men

rh

6/10/2012

Finding Number from the String


Protected void ChkNumFromString()
{
  Regex re = new Regex(@"\d+");
  Match m = re.Match(txtNumbers.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!";
  }
}

No comments :

Post a Comment