>我可以这样做
where Col like '%Mystring%String2%'
在 Teradata SQL 中,或者我可以将?
用于单个字符匹配。如何搜索使用 Terdata SQL 正则表达式的内容模式如下所示
String<one of more instance of spaces or non alpha chars>string2
例如 IS NOT NULL
或
IS NOT NULL
在 2 个或多个字符串之间有 1 个或多个空格或其他非字母字符实例例如,考虑这个字符串,它是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
子句变长
使用正则表达式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') > 0