I need to match string that does not contain "dc-ba" - all are literal. It has to return true for all strings that is not "ab-cd".
The hypen is creating the problem. If hypen were not there:
select ('Matched') "Status" from dual where REGEXP_LIKE('def', '[^(^dcba$)]');
Matched
select ('Matched') "Status" from dual where REGEXP_LIKE('dcba', '[^(^dcba$)]');
no rows returned
Everything is as required to this point, but when I try to apply the same with hypen:
select ('Matched') "Status" from dual where REGEXP_LIKE('dc-ba', '[^(^dc-ba$)]');
Error: ORA-12728: Invalid range in regular expression
If I try to escape the hyphen:
select ('Matched') "Status" from dual where REGEXP_LIKE('dc-ba', '[^(^dc\-ba$)]');
Matched
Which sould not be the case. It shoudl match all string other than "dc-ba".
Am I doing something wrong?