日期:2014-05-19  浏览次数:20516 次

求1正则表达式,立刻结贴.
"taee.COM\tMX   preference   =   10,   mail   exchanger   =   mta-ent.21cn.COM "
怎样从以上字符串中,用正则表达式得到   "mta-ent.21cn.COM "   ,这个值.

注:1定要用正则表达式方法哦.

------解决方案--------------------
Regex reg = new Regex( "mail exchanger = (? <server> [^\\\s]+) ");
Match amatch = reg.Match(response);
if(amatch.Success)
{
//...
}
不知道对不对
------解决方案--------------------
Regex reg = new Regex(@ "mail exchanger = (? <server> [^\\\s]+) ");
要不然不认转义字符。
可以实现
Regex reg = new Regex(@ "mail exchanger = (? <server> [^\\\s]+) ");
Match aa = reg.Match(this.TextBox1.Text);
if (aa.Success)
{
Response.Write( "Success ");
}

------解决方案--------------------
Regex reg = new Regex(@ "mail exchanger = (? <server> [^\\\s]+) ");
Match aa = reg.Match(response);
if (aa.Success)
{
Response.Write( "Success ");
}
------解决方案--------------------

string yourStr = "taee.COM\tMX preference = 10, mail exchanger = mta-ent.21cn.COM ";
string resultStr = " ";
Match m = Regex.Match(yourStr, @ "mail\s+?exchanger\s*=\s*(? <server> \S+?)$ ", RegexOptions.IgnoreCase);
if (m.Success)
{
resultStr = m.Groups[ "server "].Value;
}
------解决方案--------------------
Regex reg = new Regex(@ "mail exchanger = (? <server> [^\\\s]+) ");
Match aa = reg.Match(response);
if (aa.Success)
{
Response.Write( "Success ");
}