2017-11-18 17 views
0

Excel VBAの文字列からすべてのHTMLタグを削除します。例えばExcel VBAの文字列からHTMLタグを削除する

before_text = "text1 <br> text2 <a href = 'www.data.com' id = 'data'>text3</a> text4" 

after_text = RemoveTags(before_text) 

結果:

after_text = "text1 text2 text3 text4" 
+2

[文字列からストリップHTML]の可能性のある重複した(https://でのstackoverflow .com/questions/12804067/stripping-html-from-a-string) – Arul

答えて

1
vbscript.regexp 

コード:

Function RemoveHTML(text As String) As String 
    Dim regexObject As Object 
    Set regexObject = CreateObject("vbscript.regexp") 

    With regexObject 
     .Pattern = "<!*[^<>]*>" 'html tags and comments 
     .Global = True 
     .IgnoreCase = True 
     .MultiLine = True 
    End With 

    RemoveHTML = regexObject.Replace(text, "") 
End Function 
関連する問題