REGEXP_REPLACE [message #683146] |
Tue, 08 December 2020 10:29  |
 |
sss111ind
Messages: 628 Registered: April 2012 Location: India
|
Senior Member |

|
|
Hi All,
I have got some confusion over the result of the value please clarify it.
select
regexp_replace('1000-','-','',1)c1,--the first "-" should be replaced hence expected 1000 (correct)
regexp_replace('1000-','-','',2)c2,--the second "-" should be replaced hence expected 1000- but result is 1000 (wrong)?
regexp_replace('-1000','-','',1)c3,--the first "-" should be replaced hence expected 1000 (correct)
regexp_replace('-1000','-','',2)c4--the second "-" should be replaced hence expected -1000 (correct)
from dual;
Thank you
[Updated on: Tue, 08 December 2020 10:30] Report message to a moderator
|
|
|
Re: REGEXP_REPLACE [message #683148 is a reply to message #683146] |
Tue, 08 December 2020 10:52   |
 |
Michel Cadot
Messages: 68421 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
The fourth parameter of REGEXP_REPLACE is the position in the source string where Oracle should start to search for the pattern, the occurrence is the fifth parameter:
SQL> select
2 regexp_replace('1000-','-','',1,1)c1,
3 regexp_replace('1000-','-','',1,2)c2,
4 regexp_replace('-1000','-','',1,1)c3,
5 regexp_replace('-1000','-','',1,2)c4
6 from dual;
C1 C2 C3 C4
---- ----- ---- -----
1000 1000- 1000 -1000
[Updated on: Tue, 08 December 2020 10:52] Report message to a moderator
|
|
|
|