click <a href="javascript:validate('http://www.google.com');">here</a> to open google.com
我需要将上面的句子替换为以下内容:
click <a href="http://www.google.com">here</a> to open google.com
请帮助我使用正则表达式在 C# 中执行此操作
最佳答案
Regex regex = new Regex ("href\=\".+?'(.+)'",
RegexOptions.IgnoreCase);
MatchCollection matches = regex.Matches(text);
然后您需要提取组#1:
matches .Groups[1]
这是您要分配的新值。
关于c# - 正则表达式删除一些文本作为超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7455872/