I'm splitting a string p_value using p_delimeter, which may contain one or more symbols (that's why regexp is not like often used [^,]+).
In most of the cases the following query works predictably, but I'm dazed with a case when:
- string
p_valuecontains line breakchr(10), p_valuedoesn't containp_delimeteras substring,
so I expect to have one row with the whole p_value as the result, but got only the remainder after line break.
It's supposed here that regexp treats line break as ordinary symbol, since
the 'm' modifier is absent in call to regexp_substr.
Please, explain is this behavior correct and how to get the expected result.
WITH
params AS (SELECT 'ab' || chr(10) || 'cd' p_value,
'xxx' p_delimeter
FROM dual
)
SELECT regexp_substr(p_value, '(.*?)(' || p_delimeter || '|$)', 1, level, 'c', 1) AS CUT
FROM params
CONNECT BY regexp_substr(p_value, '(.*?)(' || p_delimeter || '|$)', 1, level, 'c', 1) IS NOT NULL;
Actual result: Expected result:
----- ------
CUT CUT
----- ------
cd ab/cd
^
'this is just a marker for a line break [= chr(10)]'