首页 > 解决方案 > 在 Redshift 中使用 regex_match 的问题

问题描述

我正在使用以下代码进行正则表达式匹配,但出现此错误:

错误:

无效操作:函数 regexp_matches(character varying, character varying) 不存在;

代码:

WHEN REGEXP_MATCHes (tdahw.referrer, 'www.*/'::text) IS NOT NULL AND     REGEXP_MATCHes(tdahw.event_value, 'www.*/'::text) = REGEXP_MATCHes(tdahw.referrer, 'www.*/'::text) AND tdahw.rolling_count = 1 THEN 'Direct'::text
WHEN REGEXP_MATCHes(tdahw.referrer, 'www.*/'::text) IS NOT NULL AND REGEXP_MATCHes(tdahw.event_value, 'www.*/'::text) <> REGEXP_MATCHes(tdahw.referrer, 'www.*/'::text) AND tdahw.rolling_count = 1 THEN 'Referrer'::text
WHEN REGEXP_MATCHes(tdahw.referrer, 'www.*/'::text) IS NULL THEN 'Referrer'::text

如何纠正?

标签: sqlregexamazon-redshift

解决方案


使用~

WHEN tdahw.referrer ~ 'www.*/'::text AND 
     tdahw.event_value ~ 'www.*/'::text AND
     tdahw.referrer ~ 'www.*/'::text AND
     tdahw.rolling_count = 1

推荐阅读