如何在 Snowflake 中从 regexp_extract 更改为 regexp_substr

How to change from regexp_extract to regexp_substr in Snowflake

我在 Hive 中有一些表达式需要更改为 Snowflake

(regexp_extract(subtransactionxml,'(.*?)()',1) in('REFUND'))

我尝试使用这个,但它给了我 0 个结果

(regexp_substr(subtransactionxml,'\W+(\W+)',1,1,'e',1) in('REFUND'))

我的错误在哪里?

根据您的示例,以下查询应该有效:

with xmldata as (
select '<transactionDate>2019-07-26T14:06:05.575-04:00</transactionDate> <type>CANCEL</type>' subtransactionxml )
select regexp_substr(subtransactionxml,'<type>(.*)<\/type>',1,1,'e',1) in ('CANCEL')
from xmldata;