Home » SQL & PL/SQL » SQL & PL/SQL » repalce the first occurance of a character
repalce the first occurance of a character [message #312575] |
Wed, 09 April 2008 05:47 |
smithagirish
Messages: 10 Registered: March 2008 Location: kochi
|
Junior Member |
|
|
Sir,
can anyone pls help me ....
i want to replace only the first occurance of a character in the given string
eg if the string is 'abcd,efg,hi,jk' then the output should be
'abcd efg,hi,jk'
thanks
|
|
|
Re: repalce the first occurance of a character [message #312579 is a reply to message #312575] |
Wed, 09 April 2008 05:58 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
SQL> select regexp_replace( 'abcd,efg,hi,jk', '^([^,]*),', '\1 ') from dual;
REGEXP_REPLACE
--------------
abcd efg,hi,jk
1 row selected.
Regards
Michel
|
|
|
|
|
|
|
|
|
|
Re: repalce the first occurance of a character [message #312594 is a reply to message #312593] |
Wed, 09 April 2008 06:55 |
rajatratewal
Messages: 507 Registered: March 2008 Location: INDIA
|
Senior Member |
|
|
Try Using Substr And Instr Functions
SELECT
SUBSTR('abcd,efg,hi,jk',1,INSTR('abcd,efg,hi,jk',',',1)-1)
||SUBSTR('abcd,efg,hi,jk',INSTR('abcd,efg,hi,jk',',',1)
+1,length('abcd,efg,hi,jk'))
FROM dual
Hope this helps
|
|
|
|
Goto Forum:
Current Time: Sat Dec 07 05:19:56 CST 2024
|