I did some research for this question. chr(0) is a thing that is causing mayhem everywhere.
I first created a table, inserted a string with chr(0) inside it and tried to find that using regexp_like.
CREATE TABLE t1(col1 VARCHAR2(10));
INSERT INTO t1 VALUES('01234' || chr(0) || '5678');
SELECT CASE WHEN REGEXP_LIKE(col1,CHR(0)) THEN 1 ELSE 0 END op,col1, dump(col1) FROM t1;
The output was below -
op col1 dump(col1)
---- ----- -------------------------------------------------
1 01234 Typ=1 Len=10: 48,49,50,51,52,0,53,54,55,56
As you can see the dump shows actually chr(0) is in there, though while showing the string on screen, the tool considers chr(0) as null terminator and does not show the rest. So it seemed that regexp_like is actually finding a match for chr(0) inside a string.
But to my utter dismay I found that the even a string without chr(0) will return the same result.
DELETE FROM t1;
INSERT INTO t1 VALUES('0123456789');
SELECT CASE WHEN REGEXP_LIKE(col1,CHR(0)) THEN 1 ELSE 0 END op,col1, dump(col1) FROM t1;
op col1 dump(col1)
----- ------- ----------------------------------------------------
1 0123456789 Typ=1 Len=10: 48,49,50,51,52,53,54,55,56,57
So there is something fishy to handle chr(0). I posted the below question and got an explanation for the same. chr(0) being a zero length string, whenever we would try to find it inside a string, it would apparently find it everywhere, effectively finding it actually nowhere.
It seems it is not possible to find chr(0) in a string. Please see the response from MTO.
CHR(0) in REGEXP_LIKE