问题
I want to replicate this regex pattern to regexp_substr. I want to capture the second group.
'(\?)(.*?)(&|$)'
I have tried this
regexp(my_url, '\\?.*?&|$')
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>>>&|$'.
回答1:
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, '\\?([^&]*)')
The pattern matches:
\?
- a question mark([^&]*)
- Group 1: zero or more chars other than&
来源:https://stackoverflow.com/questions/46495580/redshift-regexp-substr