PQ - CreateObject("VBScript.RegExp")?

PQ - CreateObject("VBScript.RegExp")?

是否可以将 VBA 用户定义的函数连接到 Power Query? PQ 可以使用自定义 Excel 之类的 UDF 操作吗? 只想使用 VBA 的正则表达式

Public Function RegExpTest(str As String, _
    Pattern As String, _
    Optional IgnoreCase As Boolean = False, _
    Optional Multiline As Boolean = False) _
As Boolean
    RegExpTest = False
    If Not str Like "" And Not Pattern Like "" Then
        Dim RegExp As Object
        Set RegExp = CreateObject("VBScript.RegExp")
        With RegExp
            .IgnoreCase = IgnoreCase
            .Multiline = Multiline
            .Pattern = Pattern
        End With
        On Error Resume Next
        RegExpTest = RegExp.Test(str)
        Set RegExp = Nothing
    End If
End Function

不,PQ 无法直接与 VBA 对话,但您可以在 Excel worksheet 之间共享数据(即加载数据到 worksheet,比 运行 VBA 超过 sheet).