Ann*_*son 5 html ms-access vba
我尝试了很多东西,但似乎没有什么工作正常.我有一个Access DB,我正在VBA中编写代码.我有一串HTML源代码,我有兴趣剥离所有HTML代码和标签,以便我只有纯文本字符串,没有html或标签.做这个的最好方式是什么?
谢谢
一种尽可能具有弹性的标记;
with createobject("htmlfile")
.open
.write "<p>foo <i>bar</i> <u class='farp'>argle </zzzz> hello </p>"
.close
msgbox "text=" & .body.outerText
end with
Run Code Online (Sandbox Code Playgroud)
Function StripHTML(cell As Range) As String
Dim RegEx As Object
Set RegEx = CreateObject("vbscript.regexp")
Dim sInput As String
Dim sOut As String
sInput = cell.Text
With RegEx
.Global = True
.IgnoreCase = True
.MultiLine = True
.Pattern = "<[^>]+>" 'Regular Expression for HTML Tags.
End With
sOut = RegEx.Replace(sInput, "")
StripHTML = sOut
Set RegEx = Nothing
End Function
Run Code Online (Sandbox Code Playgroud)
祝你好运,祝你好运.
归档时间: |
|
查看次数: |
13380 次 |
最近记录: |