Guys, I just can't explain and find any explanation in the doc for such a behaviour:
SQL> with t as (select 'the 1 january of the year 2007' str from dual)
2 select regexp_substr(str,'.*?[[:digit:]][ ][[:alpha:]]+.*') substr1,
3 regexp_substr(str,'.*?[[:digit:]][ ][[:alpha:]]+.*$') substr2
4 from t
5 /
SUBSTR1 SUBSTR2
------------- ------------------------------
the 1 january the 1 january of the year 2007
SQL
the first part of a pattern is '.*?' - non-greedy seacrh for combination of any symbols.
It is followed by 1 digit, then 1 space then a consequent greedy combination of alpha characters
an the last part of the mask is '.*' in the first case and '.*$' in the second.
The only difference in '$' in the end.
AFAIK '.*' in the first case should stand for GREEDY search of a combination of any symbols.
So in my opinion if '.*' stands in the end of the mask it should be equivalent to '.*$',
but somehow it becomes NON-GREEDY.
I just can't explain why.
Can anyone help?
Thanks.
PS
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL