Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Help with regular expression
On Sun, 25 Jun 2006 05:28:10 -0700, Barry wrote:
> 10.2 RHL; Hi I am new to regular expressions. I am trying to get the
> second word from a sentence using a regular expression. The sentence
> uses '#' instead of spaces to make easy to read in
> comp.databases.oracle.server. My query almost does what I want, but it
> still has the word surrounded by '#'. Can someone help me with the
> regular expression to do the substring excluding the '#'. I know in the
> real system where I have spaces, I can use TRIM but instead I would
> rather have the regular expression right to start with and not have to
> do this.
> Thanks
> Barry
>
>
> SQL> SELECT REGEXP_SUBSTR('return#second#word#in#sentence','#[^#]*#')
> FROM DUAL;
> 2
> REGEXP_S
> --------
> #second#
>
>
Try with this:
SQL>
1 SELECT
2 REGEXP_SUBSTR('return#second#word#in#sentence','[^#]+',1,2)
3* from dual
SQL> /
REGEXP
SQL>
-- http://www.mgogala.comReceived on Sun Jun 25 2006 - 13:19:25 CDT