Redshift regexp_substr [英] Redshift regexp_substr
本文介绍了Redshift regexp_substr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将此正则表达式模式复制到regexp_substr.我想捕获第二组.
I want to replicate this regex pattern to regexp_substr. I want to capture the second group.
'(\?)(.*?)(&|$)'
我已经尝试过了
regexp(my_url, '\\?.*?&|$')
与上述内容的一些类似变体,但我一直在犯错误:错误:XX000:重复运算符之前的无效前导正则表达式.在解析正则表达式"\?.*?>>> HERE>>>& | $'时发生错误.
And some similar variations of the above, but I have been getting the errror:
ERROR: XX000: Invalid preceding regular expression prior to repetition operator. The error occured while parsing the regular expression: '\?.*?>>>HERE>>>&|$'.
推荐答案
Since Amazon Redshift supports only POSIX regex, you need to use greedy quantifiers rather than lazy ones, but with a negated character class:
regexp(my_url, '\\?([^&]*)')
模式匹配:
-
\?
-一个问号 -
([[^&] *)
-组1:除&
以外的零个或多个字符
\?
- a question mark([^&]*)
- Group 1: zero or more chars other than&
这篇关于Redshift regexp_substr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文