c# - 正则表达式删除一些文本作为超链接

标签 c# regex

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/

相关文章:

c# - 两个类的属性类型

regex - 如何使用 bash 中的 grep 停止贪婪

Python 正则表达式 : why does this not work?

c# - 如何使用 ClosedXML 与动态列计数合并单元格?

c# - ASP.NET 4.0 : datagrid uses control state or view state

c# - Xamarin 表单 System.Reflection.TargetInitationException : 'Exception has been thrown by the target of an invocation.'

regex - 使用正则表达式匹配对标签

python - 在 Python 中的空格上拆分字符串

java - 如何使用正则表达式在同一行捕获可变数量的模式?

C# 添加 XMLNode 到 XMLNodeList