Replace Nth occurence of a string

386 views
Skip to first unread message

Vlad

unread,
Oct 14, 2008, 10:40:52 AM10/14/08
to Oracle PL/SQL
I need to replace the second occurrence of one string within another:-

E.g.

'Shoppingtrolley,Shoppingbasket'

needs to be come

'Shoppingtrolley,Emptybasket'

Any ideas?

TIA

Michael Moore

unread,
Oct 14, 2008, 1:39:45 PM10/14/08
to Oracle...@googlegroups.com
SELECT SUBSTR (mystr, 1, INSTR (mystr, ',')) || 'Emptybasket'
  FROM (SELECT 'Shoppingtrolley,Shoppingbasket' mystr
          FROM DUAL);

Vlad

unread,
Oct 16, 2008, 11:36:58 AM10/16/08
to Oracle PL/SQL
Cheers Michael ;-)
Reply all
Reply to author
Forward
0 new messages