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

正则表达 去掉A标记 进来拿分。。。。。。。。
<a   href= "asff.htm "   target= "_blank "> 文字 </a> <> 文字 <A   href= "asdf.htm "> 文字 </A>

我的要求是只剩下上面之中的字(不能删除全部html)     就是把这其中的   <a   > 标记删除掉

------解决方案--------------------
public static string GetLinkUrl(string HTMLStr)
{
string str = string.Empty;

Regex r = new Regex(@ " <a\s+[^> ]*\s*href\s*=\s*([ ']?)(? <url> \S+) '?[^> ]*> ",
RegexOptions.Compiled);
Match m = r.Match(HTMLStr.ToLower());
if (m.Success)
str = m.Result( "${url} ");
return str;
}
------解决方案--------------------
try

string yourStr = ...........;
string resultStr = Regex.Replace(yourStr, @ " </?a[^> ]*?> ", " ", RegexOptions.IgnoreCase);