简体   繁体   English

谷歌表格查找和替换正则表达式

[英]Google Sheets find and replace regex

I cannot seem to get a regexp to work in the find and replace box in my Google Sheet.我似乎无法让正则表达式在我的 Google 表格中的查找和替换框中工作。 I am trying to remove all of the - characters in any cell.我正在尝试删除任何单元格中的所有-字符。 Cells often look like this细胞通常是这样的

-something
-some other stuff
-more things that-are-here 

So I want it to end up like所以我希望它最终像

something
some other stuff
more things that-are-here 

I cannot even tell if this regexp thing supports RE2 properly.我什至无法判断这个正则表达式是否正确支持 RE2。

例子

Supposedly this should match all - characters and support multi line.据说这应该匹配所有-字符并支持多行。 But it does not.但事实并非如此。 It only removes the first - in each cell.它只删除第一个-在每个单元格中。

You can try你可以试试

(?<=\n|^)-

Here's the test result这是测试结果

  • (?<=...) Positive looksbehind (?<=...)正面回顾
  • \\n|^
    • \\n line break \\n换行
    • | or或者
    • ^ start of the string ^字符串的开始
  • - matches - literally -匹配-字面意思

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM