* operatorn är "girig" som standard
. Du tillåter alla tecken mellan distinkt och ) , i vilken mängd som helst. och inklusive den första
Som EatÅPeach föreslog, kan du göra det icke-girigt med ? :
Så här, med .*? istället för .* :
select regexp_substr(
'select count(distinct empno), count(distinct deptno) from emp',
'count\(distinct.*?\)')
from dual;
Eller så kan du ange att det ska vara vilket tecken som helst förutom ) med [^)]* istället för .* .
select regexp_substr(
'select count(distinct empno), count(distinct deptno) from emp',
'count\(distinct[^)]*\)')
from dual;