我能做这些
where Col like '%Mystring%String2%' 在Teradata中,或者我可以使用?来匹配单个字符。如何使用Terdata SQL Regex搜索类似于此的内容模式?
String<one of more instance of spaces or non alpha chars>string2,例如IS NOT NULL或
IS NOT NULL在两个或多个字符串中有一个或多个空格或其他非alpha字符的实例,例如,假设这个字符串是PDCR数据库中的sqltext的一部分
sel t1.c1, t2.c2, t3.c3 from
t1 , t2 ,t3
where t2.Cx is NULL and t3.cy IS NOT NULL and
t3.Ca is NULL AND
t3.cb is NULL AND t3.c7 is NOT NULL
and t3.c10 not like any ('%searchstring%','%string%','%||||%')注意NOT和NULL以及IS和NULL之间空间的变化。
因此,我想要形成where子句,检查各种非alpha条件,比如(这是类似的伪代码)。对不起)
where Sqltext like '%NOT<1 or more instances of Spaces only>NULL%'
or SQLtext like '%,\%<one or more instances of | character%' escape '\'那就是我要找的。REGEXP_SIMILAR看起来很有前途。试图了解如何使用where子句来长时间
发布于 2016-03-09 09:14:28
使用regex \s查找空白(空格、选项卡、CRLF):
WHERE REGEXP_SIMILAR(col,'.*?IS[\s|\|]+NOT.*?','i') = 1
.*? -- any characters
IS -- 1st string
[\s|\|]+ -- one or more whitespaces and/or |
NOT -- 2nd string
.*?' -- any characters或者REGEXP_INSTR,因为您不需要开头和结尾的“任何字符”,所以它要短一点:
WHERE REGEXP_INSTR(x,'IS[\s|\|]+NOT',1,1,0,'i') > 0https://stackoverflow.com/questions/35877393
复制相似问题