日期:2014-05-17 浏览次数:21177 次
string source = "xxx.com xxxx.com xxxx.cc";
Regex reg = new Regex(@"[\S]{3,4}.[\S]+");
MatchCollection mc = reg.Matches(source);
foreach (Match m in mc)
{
MessageBox.Show(m.Value);
}
------解决方案--------------------
int num=4;//定义位数
string pattern_domain = string.Format(@"(?i)(?<=^|\s)\S{{{0}}}\.com(\.cn)?",num);
string[] temp_arr = Regex.Matches(domains, pattern_domain).Cast<Match>().Select(a => a.Value).ToArray();