Oracle SQL regular expression question

From: oneluvbj <nickli2000_at_gmail.com>
Date: Thu, 29 Jan 2015 10:33:13 -0800 (PST)
Message-ID: <b42a849d-e9a9-4e8d-9cc8-7fdf27f43d48_at_googlegroups.com>



Hi,  

I am trying to test Oracle regular expressions on Oracle 11g 2.0.3.0 and I am having an issue with the following query to check phone numbers:  

select regexp_substr('(666)888-0000','[0-9]{3}|\([0-9]{3}\)') PHONE_1,

       regexp_substr('666(888)-0000','[0-9]{3}|\([0-9]{3}\)') PHONE_2 from dual;  

The query will return the following:  

PHONE_1       PHONE_2      
(666)         666
 

My question is about the return value of PHONE_1. I was expecting the query to return "666" for PHONE_1 instead of "(666)". After I changed the number from '(666)888-0000' to ' 666(888)-0000', I am getting the expected result for PHONE_2.  

Please advise on this.  

Thanks in advance.  

Nick Li Received on Thu Jan 29 2015 - 19:33:13 CET

Original text of this message