【问题标题】:How to include parentheses inside regex formula as a part of formula in google sheet如何在正则表达式公式中包含括号作为谷歌表格中公式的一部分
【发布时间】:2021-10-19 23:08:58
【问题描述】:

我有一张 Google 表格,其中有一列中有文本字符串。下面是一个文本字符串的示例。

We  are  looking  for  a  ".NET  Developer"  who  will  be  working  closely  with  business  analysts  and  team  members  to  understand  business  requirements  that  drive  the  analysis  and  design  of  quality  technical  solutions.salary:9000. We  are  now  preferably  looking  for  Candidates  who  are  all  residing  in  UAE. Please  send  your  CV  to  test@test.com ,with  Subject  title  "Dot  Net  Developers"

我想通过在某些字符和单词后留出额外的空格来格式化下一列中的上述文本字符串。喜欢 。 : , " / .com 工作地点 .ae

我使用了以下公式,该公式对除括号外的每个字符都适用。如何在文本字符串中找到括号前后留出空格。 “.NET 开发者”

=REGEXREPLACE(A2,"(:|/|.com|job location|.ae)","$1 ")

【问题讨论】:

    标签: regex google-apps-script google-sheets conditional-statements regexp-replace


    【解决方案1】:

    您需要通过在括号之前设置反斜杠来转义括号,例如。 \( 这将告诉正则表达式您正在寻找该字符。

    这应该找到开始、结束括号和双引号(:|\/|.com|job location|.ae|\(|\)|\")

    我已经发了a demonstration here

    【讨论】:

    • 我在谷歌表格中使用它给出错误
    【解决方案2】:

    引号或括号?文本字符串中没有括号。 “.NET Developer”,所以如果引号

    =REGEXREPLACE(A2,"(:|/|"&""""&"|.com|job location|.ae)","$1 ")
    

    【讨论】:

    • 引号不是括号
    【解决方案3】:

    它对我有用:

    =REGEXREPLACE(REGEXREPLACE(A2,"(\(|\)|:|/|.com|job location|.ae)"," $1 "), "[\(\)]", " $0 ")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-16
      • 2021-05-03
      • 1970-01-01
      • 2020-03-06
      • 1970-01-01
      • 2019-11-10
      • 1970-01-01
      相关资源
      最近更新 更多