常见论坛隐藏文字 消去法 (VB.NET)
% |# m J! x( }" n# L3 @& I: e
1 p6 z8 E8 D8 k7 W
现在很多论坛 为了防止copy,常会加上 隐藏文字,如开头两行
我使用 规则运算式 (Regular Expression) 搭配Replace 来解码
先Imports System.Text.RegularExpressions
'消掉前面隐藏字
Dim ex As New Regex("]*>(?:[^<]+|<(?!tableb[^>]*>))*?")
For Each m As Match In ex.Matches(TextBox1.Text)
For Each c As Capture In m.Captures
TextBox1.Text = Replace(TextBox1.Text, c.Value, "")
Next
Next
'消掉后面隐藏字
Dim ex2 As New Regex("]*>(?:[^<]+|<(?!tableb[^>]*>))*?")
' Dim ex2 As New Regex("<(?!br|/?p|b|/?font|font color)[^>]*>")
For Each m As Match In ex2.Matches(TextBox1.Text)
For Each c As Capture In m.Captures
' Debug.Print(c.Value)
TextBox1.Text = Replace(TextBox1.Text, c.Value, "")
Next
Next
如有错误 欢迎指正