Teradata SQL :查询包含空格的模式列(a.k.a 一个 where 子句以在字符串中搜索包含空格的模式)
Teradata SQL : Query a column for pattern that has spaces ( a.k.a a where clause to search for a pattern that has spaces, in a string )
我能做到
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
查找白色space(space,制表符,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,因为您不需要在开始和结束处使用 "any characters":
WHERE REGEXP_INSTR(x,'IS[\s|\|]+NOT',1,1,0,'i') > 0
我能做到
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
查找白色space(space,制表符,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,因为您不需要在开始和结束处使用 "any characters":
WHERE REGEXP_INSTR(x,'IS[\s|\|]+NOT',1,1,0,'i') > 0