Google表格:Regexextract

时间:2018-12-15 23:38:15

标签: regex google-sheets google-sheets-formula

我正在使用Google表格和REGEXEXTRACT公式来提取范围内的所有字母/数字/连字符。在下面的示例中,我希望删除撇号。

'02蓝色扭转者

Blue Twisters '02

蓝色扭曲者02-03

=ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"\w+\w+\w+"))) =ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"w.+"))) =ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"w+"))) =ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"[a-zA-Z0-9].+))) =ARRAYFORMULA(IF(DN3:DN="","",REGEXEXTRACT(DN3:DN,"[a-zA-Z0-9]+")))

\w+似乎可以按预期HERE正常工作,但是它们似乎并不能解决Google表格中的问题。有些删除了第一个撇号,但内部没有删除。有些不会去除任何东西。

关于我可能会丢失的任何想法

3 个答案:

答案 0 :(得分:1)

  

关于我可能会丢失的任何想法

SUBSTITUTE

答案 1 :(得分:0)

感谢大家的帮助,我遇到了两个解决方案。它们有点复杂,但是可以工作。

=ARRAYFORMULA(IF(ISNUMBER(SEARCH("(",H3:H))=TRUE,TRIM(REGEXREPLACE(H3:H,"\(|\)","")),IF(ISNUMBER(SEARCH("'",H3:H))=TRUE,TRIM(REGEXREPLACE(H3:H,"'","")),H3:H)))

=ARRAYFORMULA(IF(DN3:DN="","",TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(DN3:DN,"("," "),")"," "),"'"," "),":"," "),";"," "),"!"," "),","," "),"."," "))))

答案 2 :(得分:0)

  

提取一个范围内的所有字母/数字/连字符。

=REGEXREPLACE(A2, "[^A-Za-z0-9-]",)