代码之家  ›  专栏  ›  技术社区  ›  anat

在BigQuery中的特定字符串后查找n个字符

  •  0
  • anat  · 技术社区  · 3 年前

    我想得到sql中“hello_u2;”之后的前4个字符

    以下是示例字符串:

    "hello_abcd_gjfnjg" , "hello_ab12_tg23" 
    

    期望输出:

    "abcd", "ab12"
    

    下面是我的正则表达式:

    (hello_)(....)
    

    但我得到了一个错误,因为它是分组的:

    Regular expressions passed into extraction functions must not have more than 1 capturing group
    

    有没有不分组的更简单的正则表达式?

    1 回复  |  直到 3 年前
        1
  •  2
  •   anotherGatsby    3 年前

    您可以只使用一个捕获组,如下所示: hello_(.{4})

    在这里测试正则表达式: https://regex101.com/r/QZPc3r/1