Aar*_*ers 5 html vb.net asp.net
我需要过滤掉字符串中的锚标签.例如,
Check out this site: <a href="http://www.stackoverflow.com">stackoverflow</a>
我需要能够将锚标记过滤掉:
Check out this site: http://www.stackoverflow.com
那种格式也许不一定.锚标签可能还有其他属性.此外,字符串中可能有多个锚标记.我在进入数据库之前在vb.net中进行过滤.
小智 8
这是一个应该有效的简单正则表达式.
Imports System.Text.RegularExpressions
' ....
Dim reg As New Regex("<a.*?href=(?:'|"")(.+?)(?:'|"").*?>.+?</a>")
Dim input As String = "This is a link: <a href='http://www.stackoverflow.com'>Stackoverflow</a>"
input = reg.Replace(input, "$1", RegexOptions.IgnoreCase)
Run Code Online (Sandbox Code Playgroud)