Hou*_*und 2 regex amazon-web-services amazon-redshift
我想将此正则表达式模式复制到 regexp_substr。我想捕获第二组。
'(\?)(.*?)(&|$)'
Run Code Online (Sandbox Code Playgroud)
我试过这个
regexp(my_url, '\\?.*?&|$')
Run Code Online (Sandbox Code Playgroud)
以及上面的一些类似的变体,但我一直收到错误:
ERROR: XX000: Invalid preceding regular expression prior to repetition operator. The error occured while parsing the regular expression: '\?.*?>>>HERE>>>&|$'.
由于 Amazon Redshift仅支持 POSIX 正则表达式,因此您需要使用贪婪量词而不是惰性量词,但具有否定字符类:
regexp(my_url, '\\?([^&]*)')
Run Code Online (Sandbox Code Playgroud)
模式匹配:
\?- 一个问号([^&]*)- 第 1 组:零个或多个字符,除了&