VBA使用正则表达式替换东西

时间:2016-02-04 15:52:11

标签: regex excel-vba vba excel

我之前从未做过VBA,而且我不熟悉xD编程 我试图从包含html描述的列表中删除一些东西,但它不起作用。

任何建议我在这里做错了什么可怕的事情?

Function entferne_sonstige_zeichen(description)

entferne_sonstige_zeichen = description

Dim oRegExp As RegExp
Set oRegExp = New RegExp
With oRegExp
.IgnoreCase = False
.Global = True
.MultiLine = True
.Pattern = "[^A-Za-z\d,/-]"
End With

Dim ReplacePattern As String
ReplacePattern = ""

description = oRegExp.Replace(ReplacePattern)

End Function

1 个答案:

答案 0 :(得分:0)

也许......

Function entferne_sonstige_zeichen(str As String) As String

Dim objRegex As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
    .IgnoreCase = False
    .Global = True
    .MultiLine = True
    .Pattern = "[^A-Za-z\d,/-]"
    .ignorecase = True
    entferne_sonstige_zeichen = .Replace(str, vbNullString)
End With

End Function
相关问题