[从Google表格中的单元格中删除“和= +

问题描述 投票:0回答:2

我有类似的单元格

"Apple"
=+Organe +is +good
"Mango"

我想删除所有字符,即="+

尝试过=SUBSTITUTE(C3,"+" ,"",1)但没有成功

我正在使用Google表格,并且不能使用Excel(在MAC中)

regex google-sheets google-sheets-formula array-formulas substitution
2个回答
0
投票

如果您知道应删除哪些字符,应删除多少个字符 N个嵌套的替换项将起作用。只要确保输入单元格没有错误即可:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"="," "),"+"," "),"""","")

enter image description here

[如果需要排除字母A到Z和0到9之间的数字,VBA + RegEx生效:

enter image description here

Public Function RemoveNonAlphabetChars(inputString As String) As String

    Dim regEx           As Object
    Dim inputMatches    As Object
    Dim regExString     As String

    Set regEx = CreateObject("VBScript.RegExp")

    With regEx
        .Global = True
        .Pattern = "[^a-zA-Z0-9]"
        .ignoreCase = True
        Set inputMatches = .Execute(inputString)

        If regEx.test(inputString) Then
            RemoveNonAlphabetChars = .Replace(inputString, vbNullString)
        Else
            RemoveNonAlphabetChars = inputString
        End If
    End With

End Function

0
投票

尝试:

=ARRAYFORMULA(REGEXREPLACE(A1:A, "[=\+""]", ))

0


或者如果您想使用SUBSTITUTE,则:

=ARRAYFORMULA(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1:A, "=", ), "+", ), """", ))

0

© www.soinside.com 2019 - 2024. All rights reserved.