如何用正则表达式找到它

时间:2010-08-02 09:54:29

标签: c# regex

  

可能重复:
  What is the best regular expression for validating email addresses?

您好

如何查找带有正则表达式的电子邮件?

"sdafsad@asdfsa.com"
"sdaf-sad@asdfsa.com"
"sdaf-sad@asdfsa.com"
"sdaf-sad@asdf-sa.com"
"sdaf_sad@asdf-sa.com"

另外,我如何才能找到这些物品:

track0; (any track number);
track50 (any track number);
Track 0 (any track number);
Track 10 (any track number);
Track10 (any track number);

3 个答案:

答案 0 :(得分:1)

\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

http://www.regular-expressions.info/email.html

上找到

答案 1 :(得分:0)

1)直接来自Microsoft:How to match a pattern by using regular expressions and Visual C#

using System.Text.RegularExpressions;
Regex emailregex = new Regex("(?<user>[^@]+)@(?<host>.+)");
Match m = emailregex.Match(s);

2)您想要验证具有该格式的所有条目,还是只想获得“(任何曲目编号)”值?

答案 2 :(得分:0)

首先,尝试搜索或使用Regular Expression Library

其次,试试这个:

Regex regex = new Regex(@"[^\d]+\d");