可以分别过滤html代码和提取图片:
过滤html代码:
Function AspHtml(HtmlStr) Set re = New RegExp re.Pattern ="<[^>]+>" re.Global = True re.IgnoreCase = False re.MultiLine = True AspHtml= re.Replace(HtmlStr,"") End Function
提取最后一张图片:
Function GetImageURL(strText) Dim RegEx, Matches, tmpStr Set RegEx = New RegExp RegEx.IgnoreCase =True RegEx.Pattern = "<img.+?>" RegEx.Global = True Set Matches = RegEx.Execute(strText) 'strText = Matches().Value For Each Match in Matches strText=match.value next If Instr(strText, "src=""") <> 0 Then tmpStr = Left(strText,Instr(strText, "src=""") + 4) tmpStr = Replace(strText, tmpStr, "") tmpStr = Left(tmpStr,Instr(tmpStr, """")-1) strText = tmpStr ElseIf Instr(strText, "src='") <> 0 Then tmpStr = Left(strText,Instr(strText, "src='") + 4) tmpStr = Replace(strText, tmpStr, "") tmpStr = Left(tmpStr,Instr(tmpStr, "'")-1) strText = tmpStr ElseIf Instr(strText, "src=") <> 0 Then tmpStr = Left(strText,Instr(strText, "src=") + 3) tmpStr = Replace(strText, tmpStr, "") tmpStr = Left(tmpStr,Instr(tmpStr, " ")-1) strText = tmpStr End If GetImageURL = strText End Function |