我在 VB.NET 中使用这些正则表达式,它们都单独工作:
texto = "ola <a href=""http://www.aiaia.pt"">coisas</a> tas <object> zborgind </object> bom <iframe src=""http://www.uiuiuiuiiu.pt""></iframe> hoje? <center>qq coisa</center> Já acabou, <script>document.write(""oi"")</script> ...agora!"
Dim regEx2 As New Regex("<a[^>]*>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
texto = regEx2.Replace(texto, String.Empty)
regEx2 = New Regex("</a[^>]*>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
texto = regEx2.Replace(texto, String.Empty)
regEx2 = New Regex("<object.*?>.*</object\s*?>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
texto = regEx2.Replace(texto, String.Empty)
regEx2 = New Regex("<iframe.*?>.*</iframe\s*?>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
texto = regEx2.Replace(texto, String.Empty)
regEx2 = New Regex("<center[^>]*>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
texto = regEx2.Replace(texto, String.Empty)
regEx2 = New Regex("</center[^>]*>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
texto = regEx2.Replace(texto, String.Empty)
regEx2 = New Regex("<script[^>]*>([\w\W]*?)</script>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
texto = regEx2.Replace(texto, String.Empty)
我怎样才能在一个表达式中加入它们?
我尝试将它们合二为一:
Dim texto2 As String = "ola <a href=""http://www.aiaia.pt"">coisas</a> tas <object> zborgind </object> bom <iframe src=""http://www.uiuiuiuiiu.pt""></iframe> hoje? <center>qq coisa</center> Já acabou, <script>document.write(""oi"")</script> ...agora!"
Dim re As New Regex( _
"^<a[^>]*>$" & _
"^</a[^>]*>$" & _
"^<object.*?>.*</object\s*?>$" & _
"^<iframe.*?>.*</iframe\s*?>$" & _
"^<center[^>]*>$" & _
"^</center[^>]*>$" & _
"^<script[^>]*>([\w\W]*?)</script>$", _
RegexOptions.IgnoreCase Or RegexOptions.Multiline _
)
但不起作用。你能帮助我吗?提前致谢。