Regex VBA使用正则表达式替换内容

Regex VBA使用正则表达式替换内容,regex,excel,vba,Regex,Excel,Vba,我以前从未做过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

我以前从未做过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
也许

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

它以什么方式失败?您需要在替换之前显示文本,并在替换之后显示您希望看到的内容,以及描述失败的内容。我有一个html描述,可以包含像“%#§”这样的符号,我尝试用这个函数使用正则表达式删除它们