【问题标题】:Redshift regexp_substr红移 regexp_substr
【发布时间】:2018-03-11 18:11:06
【问题描述】:

我想将此正则表达式模式复制到 regexp_substr。我要抓第二组。

'(\?)(.*?)(&|$)'

我试过了

regexp(my_url, '\\?.*?&|$')

上面还有一些类似的变体,但我一直收到错误消息: ERROR: XX000: Invalid preceding regular expression prior to repetition operator. The error occured while parsing the regular expression: '\?.*?>>>HERE>>>&|$'.

【问题讨论】:

  • 试试'(\?)([^&]*)'
  • 可能不支持惰性量词.*?

标签: regex amazon-redshift


【解决方案1】:

由于 Amazon Redshift supports only POSIX regex,您需要使用贪婪量词而不是惰性量词,但使用 否定字符类

regexp(my_url, '\\?([^&]*)')

模式匹配:

  • \? - 问号
  • ([^&]*) - 第 1 组:& 以外的零个或多个字符

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-19
    • 1970-01-01
    • 2014-11-16
    • 2014-02-19
    • 2019-01-19
    相关资源
    最近更新 更多