Re: Regular Expressions; return a buried match

From: Álvaro G. Vicario <alvaro.NOSPAMTHANX_at_demogracia.com.invalid>
Date: Thu, 04 Feb 2010 13:26:41 +0100
Message-ID: <hkeee3$b7g$1_at_news.eternal-september.org>



El 03/02/2010 23:43, cate escribió/wrote:
> select REGEXP_SUBSTR(encodedField, '^\d{4}(\d\d)') from table;
>
> I want the 5th and 6th digit. Can Oracle do this?

I once did similar stuff inside a function. I did something like this:

     IP1 := TO_NUMBER(REGEXP_SUBSTR(IP_CADENA, '[0-9]+', 1, 1));
     IP2 := TO_NUMBER(REGEXP_SUBSTR(IP_CADENA, '[0-9]+', 1, 2));
     IP3 := TO_NUMBER(REGEXP_SUBSTR(IP_CADENA, '[0-9]+', 1, 3));
     IP4 := TO_NUMBER(REGEXP_SUBSTR(IP_CADENA, '[0-9]+', 1, 4));

This should work on Oracle 10 or greater.

-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Received on Thu Feb 04 2010 - 06:26:41 CST

Original text of this message