Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Introduction to regular expressions part4

Aketi JyuuzouJul 6 2010 — edited Jul 22 2010
from 437109

Hi cd_2.
You has not introduced 11gR1 regex new features.
Therefore I will introduce it B-)

***********************************************************************************
RegExp_Count
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/functions145.htm

Since Oracle11gR1 There is new function RegExp_Count
RegExp_Count counts how many strings which has match pattern.

sampleSQL
select
RegExp_Count('abc','[a-cas cnt1,
RegExp_Count('abc','[ac as cnt2,
RegExp_Count('abc','[0-9as cnt3
from dual;

cnt1  cnt2  cnt3
----  ----  ----
   3     2     0
***********************************************************************************
6th parameter of RegExp_SubStr
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/functions148.htm

Since Oracle11gR1 There is new 6th parameter at RegExp_SubStr.
This 6th parameter can emulate regex Lookahead and lookbehind.
but This can emulate easy case only.
for ex (?=.*abc)ghi can emulate.
But (?=.*abc)(?=.*def)ghi cannot emulate.

sampleSQL
select
RegExp_Substr('abc1def2','([a-z])[0-9]',1,1,null,1)
as "emulate [a-z](?=[0-9])",
RegExp_Substr('1def2','[a-z]([0-9])',1,1,null,1)
as "emulate (?<=[a-z])[0-9]"
from dual;

e  e
-  -
c  2
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2010
Added on Jul 6 2010
4 comments
4,153 views