string aa="2009.4.23-=2009.4.28-=2009.5.5-=2009.5.13-=2009.5.18-=2009.5.26.-=[][][][www.gp99368.com.cn看你这点出息.看我的六万股拿到十元.用点钞<SPAN id=as>120.37.352.*</SPAN> http://www.csdn.com ........... 该网内容查看: http://00b21.uy.tf `........... http://00b13.uy.tf";我要取出www.gp99368.com.cn的.cn
www.csdn.com 的.com
00b21.uy.tf 的.tf
00b13.uy.tf 的.tf
也就是字符串中所有域名的最后的域。我的正册表达式
string re = @"\.[A-Za-z0-9]+(\.[A-Za-z]{2,})[^A-Za-z0-9\.]";
最后一个00b13.uy.tf 的.tf 取不到。改成string re = @"\.[A-Za-z0-9]+(\.[A-Za-z]{2,})";
www.gp99368.com.cn会取到.com高手来看看,谢谢
www.csdn.com 的.com
00b21.uy.tf 的.tf
00b13.uy.tf 的.tf
也就是字符串中所有域名的最后的域。我的正册表达式
string re = @"\.[A-Za-z0-9]+(\.[A-Za-z]{2,})[^A-Za-z0-9\.]";
最后一个00b13.uy.tf 的.tf 取不到。改成string re = @"\.[A-Za-z0-9]+(\.[A-Za-z]{2,})";
www.gp99368.com.cn会取到.com高手来看看,谢谢
string s = @"(?:\w+\.)+([a-zA-Z]+)";
Match m = Regex.Match(aa, @"(\w+\.)+(\w+)");
while (m.Success)
{
string str1 = m.Groups[2].Value.ToString();
m = m.NextMatch();
}
string reg = "(?:\w+\.)+(\w{2,})";
string re = @"\.[A-Za-z0-9]+(\.[A-Za-z]{2,})[^A-Za-z0-9\.]";
最后一个00b13.uy.tf 的.tf 取不到。 ----------------------------------------------------\.[A-Za-z0-9]+(\.[A-Za-z]{2,})(?![A-Za-z0-9\.])试试
MatchCollection mc = re.Matches("text");
foreach (Match ma in mc)
{
}