如何提取 phone 数字并拆分到 Google sheet 中的列?

How to extract phone number and split to column in Google sheet?

我正在尝试以这种格式 (123) 456-7890 提取 phone 个数字,并将每个数字放在一个单独的列中,格式为 1234567890,没有 space、破折号或括号。

我能够在 Excel 中使用下面来自另一个 Whosebug 问题的 VBA 代码实现这一点,但无法在 Google sheet


Sub ewqre()
    Dim str As String, n As Long, rw As Long
    Dim rgx As Object, cmat As Object, ws As Worksheet

    Set rgx = CreateObject("VBScript.RegExp")
    Set ws = Worksheets("Sheet4")

    With rgx
        .Global = True
        .MultiLine = True
        'phone number pattern is: ###-###-####
        .Pattern = "/^(\d{3})(\d{3})(\d{4})$/"
        For rw = 2 To ws.Cells(Rows.Count, "A").End(xlUp).Row
            str = ws.Cells(rw, "A").Value2
            If .Test(str) Then
                Set cmat = .Execute(str)
                'populate the worksheet with the matches
                For n = 0 To cmat.Count - 1
                    ws.Cells(rw, Columns.Count).End(xlToLeft).Offset(0, 1) = cmat.Item(n)
                Next n
            End If
        Next rw
    End With

    Set rgx = Nothing: Set ws = Nothing

End Sub
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(TO_TEXT(SPLIT(
 REGEXREPLACE(A2:A, "\(|\)|\-| ", ""), CHAR(10))), "\d+")))


或:

=ARRAYFORMULA(REGEXREPLACE(REGEXEXTRACT(SPLIT(A2, CHAR(10)), 
 "\((.*)\(.T"),"\)|\s|\-", ""))

真正的数组公式为:

=ARRAYFORMULA(IFERROR(REGEXREPLACE(REGEXEXTRACT(SPLIT(A2:A, CHAR(10)), 
 "\((.*)\(.T"),"\)|\s|\-", "")))