Re: Find the next word using regular expressions in Oracle 10g

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Mon, 9 Feb 2009 20:28:13 +0100
Message-ID: <499083d0$0$26714$426a34cc_at_news.free.fr>


"Maxim Demenko" <mdemenko_at_gmail.com> a écrit dans le message de news: 4990734F.7060206_at_gmail.com...
| admin_at_rbtron.com schrieb:
| > Hi,
| >
| > I have the following details in a file:
| >
| > (ADDRESS =
| > (CITY_DETAILS = (STREET# = 416)
| > (STREET_NAME =
| > UNITY BLVD.)
| > (CITY = AUSTIN))
| > (STATE_DETAILS = (STATE_NAME =
| > TEXAS)(ZIPCODE = 12345)))
| >
| > I need to pull word after the word STATE_NAME. In this case it is
| > TEXAS. The required word will be enclosed within '=' and ')'. These
| > are multiple line rows.
| >
| > How to do this using regular expressions in Oracle 10g please ?
| >
| > Thanx
| >
| > -GC

|

| Somewhat like this ?
|

| SQL> with t as (
| 2 select '(ADDRESS =
| 3 (CITY_DETAILS = (STREET# = 416)
| 4 (STREET_NAME =
| 5 UNITY BLVD.)
| 6 (CITY = AUSTIN))
| 7 (STATE_DETAILS = (STATE_NAME =
| 8 TEXAS)(ZIPCODE = 12345)))' s
| 9 from dual)
| 10 select
| 11 regexp_replace(s,'.*STATE_NAME\s*=\s*(\w+).*','\1',1,1,'mn') rr
| 12 from t
| 13 ;
|

| RR
| -----
| TEXAS
|
|

| Best regards

|
| Maxim

Great, 'n' match parameter is the one I missed.

Regards
Michel Received on Mon Feb 09 2009 - 13:28:13 CST

Original text of this message