Reputation: 33
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:
ABCD
ABCDE
ABCDGH
ABCDF
ABCDUYR
I need to get all except ABCDE
I tried REGEXP_LIKE(column,'^ABCD[^E]')
But this also omits ABCD.
Please help.
Thanks!
Upvotes: 2
Views: 2438
Reputation: 49260
To exclude strings that contain E
followed by ABCD
use
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.
Upvotes: 1
Reputation: 27
Try this:
REGEXP_LIKE(column,'^ABCD[^E]*')
*
matches zeros or more characters
Upvotes: 1