I am writing a sql, and I am using regexp_replace function for this.
My aim is to replace the characters like '|', '\' etc with '-'.
The problem which I am facing is that it replaces the '+', which is at the beginning.
For eg:
The phone number is: +49 |0| 941 78878544
I have to repalce the '|' with '-'.
My code is this:SELECT regexp_replace(phone,'\D','-') FROM PHONE_TBL WHERE EMPLID = employee;
I get the output as: -49--0--941-78878544
This code replaces the space , along with the '+' in the beginning.
I want the '+' to remain, if it is there in the beginning, and if phone numbers have spaces among them, that also should remain.
For '+', I have figured out i should match the beginning of the string, then,must check for non numeric digit, and then escape, but not able to code.
And for space in between, similar approach.
Any help in this, thanks.