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

正则表达式--如何取消网址的链接?
下面这段是将用户输入的Url替换成带链接的
Regex   urlregex   =   new   Regex(@ "(http:\/\/([\w.]+\/?)\S*) ",RegexOptions.IgnoreCase   |   RegexOptions.Compiled);
                signature   =   urlregex.Replace(signature,   " <a   href=\ "$1\ "   target=\ "_blank\ "> $1 </a> ");

怎么将上面的东西再还原成无链接的?

------解决方案--------------------
try

string yourStr = ......;
string result = Regex.Replace(yourStr, @ " <a\s[^> ]*> ([^ <]*) </a> ", "$1 ", RegexOptions.IgnoreCase);