1,502
社区成员
发帖
与我相关
我的任务
分享
Private Sub Form_Load()
Dim strData$, strResult$
Dim reg As Object
Dim matchs As Object, match As Object
Set reg = CreateObject("vbscript.regexp")
strData = "网页代码"
reg.Global = True
reg.IgnoreCase = True
reg.Pattern = "[\u4e00-\u9fa5:]+\d*"
Set matchs = reg.Execute(strData)
For Each match In matchs
If InStr(strResult, match & "|") = 0 Then strResult = strResult & match & "|"
Next
If strResult <> "" Then strResult = Left(strResult, Len(strResult) - 1)
MsgBox strResult
End Sub
Dim myRegExp
Set myRegExp = New RegExp
myRegExp.Pattern = """title"">+(.*?)<[\s\S]*=""tt"">+(.*?)<+(?:.*?)>+(.*?)<+(?:.*?)>+(.*?)<+(?:.*?)>+(.*?)<(?:.*?)>+(.*?)<+"
s = Replace(s, "<>", "", , 1)
s = Replace(s, "<>", "")
Private Sub Form_Load()
Dim s As String, ss As String
s = "<dslkjfljfjfk><aklsdjljfdjfoiuofiufoiuofiuofiuofiuofuofuoi??>sdk<dkjofjoifuoiufoiufoufoiuofuofiu><jdoiufoiufouffoiufoiu>地方军阀三剑客《<dlkfjjfsjfl>"
Do
ss = CutString(1, s, "<", ">")
s = Replace(s, ss, "")
s = Replace(s, "<>", "", , 1)
Loop While CutString(1, s, "<", ">") <> ""
Debug.Print s
End Sub
'文本截取函数
Public Function CutString(StartNum As Long, InPutString As String, LeftString As String, RightString As String)
On Error Resume Next
Dim StrLine As Long, StrLine2 As Long
StrLine = InStr(StartNum, InPutString, LeftString) + Len(LeftString)
StrLine2 = InStr(StrLine, InPutString, RightString)
CutString = Mid(InPutString, StrLine, StrLine2 - StrLine)
End Function
计算:分数</DIV></DIV>">
</form>
<div class="content">
<div class="ttt"><img src="http://ddddd.dddd.com/ddddd/ddddd.dll?ddd=D98313330373ttt63162626ttt6160tttt659" alt="英语" width="131" height="176" ></div>
<div class="ttt">
<p class="title">英语<a href="http://ttttt.tttttttt.com/ttttinfo.tttt?tttttttttttt" onclick="tttVitttnfo(t);"><ttt src=tttttttttt/butttttt.gif style='vertical-align:middle;margin-left:15px'></a><a href="http://tttt.tttttttt.com/ttttttttpingtttt.aspx?tttt=tttttttt"><ttt src=tttttttttt/ttttt_ttttt_-if.gif style='vertical-align:middle;margin-left:15px'></a></p>
<p class="tt">计算:分数<span>|</span>>听力:98 <span>|</span>>写作:99 <
Private Sub Form_Load()
MsgBox (RegExpTest2(">([^<]+)<", Text1.Text)) '> 和<间的内容
End Sub
Function RegExpTest2(patrn, strng)
Dim regEx, Match As Match, Matches ' Create variable.
Dim RetStr As String, strSubValue
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match In Matches ' Iterate Matches collection.
strSubValue = Trim$(Match.SubMatches(0)) '去首尾空格
strSubValue = Replace$(strSubValue, vbCrLf, "") '去回车换行符
If (Len(strSubValue) > 0) Then '有有效内容
' RetStr = RetStr & "Match found at position "
' RetStr = RetStr & Match.FirstIndex & ". Value is '"
' RetStr = RetStr & strSubValue & "'." & vbCrLf
RetStr = RetStr & strSubValue
End If
Next
RegExpTest2 = RetStr
End Function
[\u4e00-\u9fa5:]+\d*
[\u4e00-\u9fa5]+(?::\d*)?