Home » SQL & PL/SQL » SQL & PL/SQL » Regexp_Substr (Oracle 10g)
Regexp_Substr [message #634098] Wed, 04 March 2015 08:00 Go to next message
Xandot
Messages: 235
Registered: January 2014
Location: India
Senior Member
Hello All,

Query:-
select regexp_substr('this is: a,b,c,d','[^,]+',1,1) from dual;


I want Output like :-
a
------------
but when I add ":" into the regexp:-
select regexp_substr('this is: a,b,c,d',':[^,]+',1,1) from dual;


It gives me output ": a" but I want only "a" in output.

Please help me out.


Thanks
Xandot

Re: Regexp_Substr [message #634099 is a reply to message #634098] Wed, 04 March 2015 08:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Left trim the result of your query.

Re: Regexp_Substr [message #634100 is a reply to message #634099] Wed, 04 March 2015 08:07 Go to previous messageGo to next message
Xandot
Messages: 235
Registered: January 2014
Location: India
Senior Member
Is it possible within Regular Expression ?
Re: Regexp_Substr [message #634103 is a reply to message #634100] Wed, 04 March 2015 08:14 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

You can't with regexp_substr but you can do it with regexp_replace:
SQL> select regexp_replace('this is: a,b,c,d','^[^:]*: ([^,]+),.*$','\1') from dual;
R
-
a

Re: Regexp_Substr [message #634106 is a reply to message #634103] Wed, 04 March 2015 08:23 Go to previous message
Xandot
Messages: 235
Registered: January 2014
Location: India
Senior Member
Thanks Michel. Smile
Previous Topic: Adding a row based on a value
Next Topic: Varray to Columns with defaults
Goto Forum:
  


Current Time: Thu Aug 27 15:37:21 CDT 2026