Hi,
Trying to figure out WHY the grouping match is not found for regex statements identified by 1 and 3 (highlighted in red) below. I am aware of no match for GRP2 in test cases 1 and 2. My concern is limited to the cells identified by -???- in the resultset.
- Learning purposes only -
with t (str) as
(
select '00b11a22a' from dual
)
,regex (id,r) as
(
select 1,'^.*?b(.*)' from dual union
select 2,'^.*?b(.*)$' from dual union
select 3,'^.*?b(.*?)a(.*)' from dual union
select 4,'^.*?b(.*?)a(.*)$' from dual
)
select
r, id,
regexp_substr(str, r, 1, 1, null, 1) grp1
, regexp_substr(str, r, 1, 1, null, 2) grp2
from t, regex
order by id;
R ID GRP1 GRP2
---------------- ---------- --------- ---------
^.*?b(.*) 1 -???-
^.*?b(.*)$ 2 11a22a
^.*?b(.*?)a(.*) 3 11 -???-
^.*?b(.*?)a(.*)$ 4 11 22a
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE 12.1.0.2.0 Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production