Oracle REGEXP_LIKE -搜索字符串后面没有特定的字符

时间:2022-09-13 09:01:18

I am looking to match string which is not followed by one character but can be followed by 0 or more of any other characters using REGEXP_LIKE in Oracle. For example, if I have these records:

我正在寻找匹配字符串,该字符串不遵循一个字符,但是可以在Oracle中使用REGEXP_LIKE来跟踪0或更多其他字符。例如,如果我有这些记录:

ABCD
ABCDE
ABCDGH
ABCDF
ABCDUYR

I need to get all except ABCDE

除了ABCDE我什么都需要

I tried REGEXP_LIKE(column,'^ABCD[^E]') But this also omits ABCD. Please help.

我的尝试REGEXP_LIKE(列,“^ ABCD[^ E]”),但这也省略了ABCD。请帮助。

Thanks!

谢谢!

2 个解决方案

#1


2  

To exclude strings that contain E followed by ABCD use

将包含E的字符串排除在ABCD使用之后。

REGEXP_LIKE(col,'^ABCD([^E]|$)')

^ABCD([^E]|$) - ABCD followed by any character(s) other than E or the string ABCD and no other characters after that.

^ ABCD(E[^]| $)- ABCD紧随其后以外的任何字符(s)E或字符串ABCD和没有其他字符。

#2


0  

Try this:

试试这个:

 REGEXP_LIKE(column,'^ABCD[^E]*')

* matches zeros or more characters

*匹配0或更多字符

#1


2  

To exclude strings that contain E followed by ABCD use

将包含E的字符串排除在ABCD使用之后。

REGEXP_LIKE(col,'^ABCD([^E]|$)')

^ABCD([^E]|$) - ABCD followed by any character(s) other than E or the string ABCD and no other characters after that.

^ ABCD(E[^]| $)- ABCD紧随其后以外的任何字符(s)E或字符串ABCD和没有其他字符。

#2


0  

Try this:

试试这个:

 REGEXP_LIKE(column,'^ABCD[^E]*')

* matches zeros or more characters

*匹配0或更多字符