[英]Regex expression from SQL to Snowflake [^''a-Z -]
The following code has to be converted to Snowflake SQL. I'm not sure how to convert the regex and also want to know if it means to negate whitespaces, alphabets and hyphen?以下代码必须转换为 Snowflake SQL。我不确定如何转换正则表达式,也想知道它是否意味着否定空格、字母和连字符?
----SQL CODE
UPDATE t1 ASET A.col1 = 'NOT VALID'
FROM t1
INNER JOIN t2 B
ON A.ID=B.ID
WHEREB.name LIKE '%[^''a-Z -]%';
This is what I tried but no idea on regex.这是我尝试过的但对正则表达式一无所知。
UPDATE t1 A
SET A.col1 = 'NOT VALID'
FROM t2 B
where A.ID=B.ID AND
RLIKE (B.name, [^''a-Z -]);
Some issues:一些问题:
aZ
(actually, nothing is). aZ
不匹配(实际上,什么都不匹配)。 That should be A-Za-z
.A-Za-z
。.*
before and after the negative character class, or use another function, like regexp_instr
.*
,或者使用另一个function,比如regexp_instr
Correction:更正:
RLIKE (B.name, '.*[^''A-Za-z -].*')
Alternatively, you could use REGEXP_INSTR
或者,您可以使用
REGEXP_INSTR
REGEXP_INSTR (B.name, '[^''A-Za-z -]') > 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.