Getting only the first occurrence of the sub string in the given string [message #623164] |
Fri, 05 September 2014 07:10 |
|
saipradyumn
Messages: 419 Registered: October 2011 Location: Hyderabad
|
Senior Member |
|
|
Hi All ,
I need only the first occurrence of sub string in total string by using regular expression.
Example
select 'Revathi ,Sharath ,Cherry , Vitech, Hyd , Chandanagr, Revathi, Vitech , XYZ , Cherry, Hyd' Single_repeation
from dual
Out should be
Revathi ,Sharath ,Cherry , Vitech, Hyd , Chandanagr, XYZ
Please help to achieve this
Thanks
Sai Pradyumn
|
|
|
|
|
|
|
|
|
|
Re: Getting only the first occurrence of the sub string in the given string [message #623203 is a reply to message #623164] |
Fri, 05 September 2014 18:27 |
Solomon Yakobson
Messages: 3273 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
XQUERY solution:
select xmlquery(
'string-join(distinct-values(ora:tokenize(.," ,"))," ,")'
passing 'Revathi ,Sharath ,Cherry ,Vitech ,Hyd ,Chandanagr ,Revathi ,Vitech ,XYZ ,Cherry ,Hyd'
returning content
).GetStringVal() Single_repeation
from dual
/
SINGLE_REPEATION
-------------------------------------------------------
Chandanagr ,Cherry ,Hyd ,Revathi ,Sharath ,Vitech ,XYZ
SQL>
SY.
|
|
|
|
|
|
|