Re: REGEXP Functions in 10g (10.2.0.2.0)

From: <stevedhoward_at_gmail.com>
Date: Fri, 7 Aug 2009 10:52:57 -0700 (PDT)
Message-ID: <5aeb5342-26b0-4a4f-955a-5942fa0438d2_at_f10g2000vbf.googlegroups.com>



On Aug 7, 11:55 am, admin <ad..._at_rbtron.com> wrote:
> On Aug 7, 7:08 am, "stevedhow..._at_gmail.com" <stevedhow..._at_gmail.com>
> wrote:
>
>
>
> > On Aug 6, 4:40 pm, admin <ad..._at_rbtron.com> wrote:
>
> > > Hi,
>
> > > Is there any way to do remove a few lines from a paragraph using
> > > regexp functions?
>
> > > Something like : sed -e '/temp/,/test/d' text.txt ?
>
> > > This is what I need:
>
> > > select 'text' title from dual union select 'test' from dual union
> > > select 'temp' from dual union select 'doc' from dual;
>
> > > TITLE
> > > --------------------------
> > > doc
> > > temp
> > > test
> > > text
>
> > > Required Output after running regexp functions:
>
> > > TITLE
> > > --------------------------
> > > doc
> > > text
>
> > > ie., remove anything between 'temp' and 'test' (inclusive) ...
>
> > > Thanks
>
> > > -Ad
>
> > How about...
>
> > SQL> select title from (
> > select 'text' title from dual
> > union
> > select 'test' from dual
> > union
> > select 'temp' from dual
> > union
> > select 'doc' from dual)
> > where not regexp_like(title,'^te[m-s]')  2    3    4    5    6    7
> > 8    9  ;
>
> > TITL
> > ----
> > doc
> > text
>
> > SQL>- Hide quoted text -
>
> > - Show quoted text -
>
> Steve,
>
> I need it in the select clause itself not in the where condition ...
> it is actually just 1 row, not 4 separate rows ... probably my "select
> union" stuff gave you wrong info ... sorry about that ...
>
> Mladen,
>
> Yeah, it is a CLOB column, that I need to "delete" certain lines (not
> rows as there is only 1 row) that start with "temp" and end with
> "test" and anything in between.
>
> I can spool it out and run sed -e '/temp/,/test/d' text.txt to get the
> desired output. I was just wondering if it is possible from within
> Oracle itself, since 10g now supports a ton of functions ...

How about...

variable title varchar2(100)
exec :title := 'text' || chr(10) || 'test' || chr(10) || 'temp' || chr (10) || 'doc'
select regexp_replace(:title,'te[m-s].+' || chr(10),'') from dual

That could get messy with languages, though. Hopefully it is a start for you.

Regards,

Steve Received on Fri Aug 07 2009 - 12:52:57 CDT

Original text of this message