regex - 从 Google 表格中的单元格中删除 " 和 =+
问题描述
我有像这样的细胞
"Apple"
=+Organe +is +good
"Mango"
我想删除所有字符 ,即=
和"
+
试过=SUBSTITUTE(C3,"+" ,"",1)
但没用
我正在使用 Google 表格,但无法使用 Excel(在 MAC 中)
解决方案
如果您知道应该删除哪些字符和多少个字符,则N 嵌套替换将起作用。只需确保输入单元格不是错误:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"="," "),"+"," "),"""","")
如果您需要排除除字母字符 A 到 Z 以及 0 到 9 之间的数字之外的任何内容,VBA + RegEx 就会发挥作用:
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
推荐阅读
- java - 关于图形坐标的Java问题
- python - Flask-SQLAlchemy - 当存在任何关系时尝试反映现有数据库时出现断言错误
- java - 为什么我的 JOptionPane 消息不起作用?
- ssl - phpmyadmin 配置期间的 SSL 警告
- angular - 如何同时检测查询参数和片段的变化(或至少以明确定义的顺序)?
- azure - az devops login 无法使用密钥环存储 PAT;回退到文件存储
- spring - Spring Security 中@PreAuthorize 和@PostAuthorize 有什么区别
- python-3.6 - Python 3.6 JSON 字符串到对象的转换
- c# - 如何用列表填充选择器
- string - '格式字符串只能是“G”、“g”、“X”、“x”、“F”、“f”、“D”或“d”。