Possible Duplicate:
Regular expression to match US phone numbers
I need to find phone numbers in html, i have seen many examples here and on google but not sure why i cannot get any one to work , it simply wont find the number .Suppose html is :
Basically i was going for all US pattern phone numbers, but any thing i found i used it but no luck i am using this code:
CODE: public static string Extractphone(string html) { StringBuilder sb = new StringBuilder();
try
{
List<string> tmpemail = new List<string>();
string data = html;
//instantiate with this pattern
Regex emailRegex = new Regex(@"(\\d{3})-(\\d{3})-(\\d{4})",
RegexOptions.IgnoreCase);
//find items that matches with our pattern
MatchCollection emailMatches = emailRegex.Matches(data);
foreach (Match emailMatch in emailMatches)
{
if (!tmpemail.Contains(emailMatch.Value.ToLower()))
{
sb.AppendLine(emailMatch.Value.ToLower());
tmpemail.Add(emailMatch.Value.ToLower());
}
// (541) 708-1364
}
//store to file
}
catch (Exception ex)
{
}
return sb.ToString();
}
I have changed the pattern many times from many examples but no luck.