Hi Tom,
I was trying to understang the regular expression from the below link
https://community.oracle.com/message/13402428#13402428 WITH sample_data AS
(
SELECT 'C,D,E' AS str, '[A-Z]?' AS pattern FROM dual
)
SELECT LEVEL
, REGEXP_SUBSTR (str, pattern, 1, LEVEL) AS greedy
, REGEXP_INSTR (str, pattern, 1, LEVEL) AS greedy_pos
, REGEXP_SUBSTR (str, pattern || '?', 1, LEVEL) AS non_greedy
, REGEXP_INSTR (str, pattern || '?', 1, LEVEL) AS non_greedy_pos
FROM sample_data
CONNECT BY LEVEL <= 7;
NON_
GREEDY_ NON_ GREEDY_
LEVEL GREEDY POS GREEDY POS
----- ------ ------- ------ -------
1 C 1 1
2 2 2
3 D 3 3
4 4 4
5 E 5 5
6 6 6
7 0 0
In this regard, one user replied like
In a technical sense i am not sure that it is totally accurate to say the regexp machine first matches the C (and then takes one step back and returns null in the case of non-greediness (laziness)).I also have the same doubt how it matches C in level 1 , then return null in level 2
Can you please explain this issue in more detail
Thanks,