简体   繁体   English

在Teradata查询中不以给定后缀结尾的字符串的正则表达式

[英]Regex for string not ending with given suffix in teradata query

I am trying to fetch the rows from database where it start with a quote sign and do not end with quote sign. 我试图从数据库中获取以引号开头且不以引号结尾的行。 I have rows as follows in the Name column, 我在“名称”列中有以下行,

"TEXT
"TEXT"
"TEST
"TEST"

Desired output from select query, 选择查询所需的输出,

"TEXT
"TEST

SQL query, SQL查询

SELECT * FROM db.supplier where  regexp_instr(Name_ ,'^[\"][\w-_.]+(?<!")') = 1;

I know the regex should be ending with $ to mark the end but it also didn't worked. 我知道正则表达式应该以$结尾以标记结束,但是它也没有用。 Any suggestion is much appreciated. 任何建议深表感谢。

How about using like ? 怎么样使用like

where Name_ like '"%' and Name_ not like '%"'

That seems simple enough. 这似乎很简单。 You could also use regexp_similar() : 您也可以使用regexp_similar()

where regexp_similar(Name_, '^".*[^"]$')

Why are you using a negative lookbehind? 为什么要在后面使用负数? This will return any values which start, but don't end with a double quote: 这将返回所有开头但不以双引号结尾的值:

where regexp_similar(Name_ ,'".+[^"]') = 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM