1
我使用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 _
)
但不起作用。你可以幫我嗎?提前致謝。
您可以使用格式化工具嗎?你也應該用英文命名你的變量,這是一個偏好... – HamZa