Remove and Replace multiple chars ( spaces, hyphen, brackets, period) from string in sql
- by Muhammad Kashif Nadeem
+39 235 6595750
19874624611
+44 (0)181 446 5697
+431 6078115-2730
+1 617 358 5128
+48.40.23755432
+44 1691 872 410
07825 893217
0138 988 1649
(415) 706 2001
00 44 (0) 20 7660 4650
(765) 959-1504
07731 508 486
please reply by email
dont have one
+447769146971
Please see the above given phone numbers. I need to replace all spaces, hyphen, period, brackets and leading 0 etc from these numbers. I need this format +447469186974
If number has leading plus sign then don't replace it otherwise I have to concatenate + sign with it.
E.G
+39 235 6595750 in this number I just need to remove spaces.
+44 (0)181 446 5697 in this i need to removes spaces and brackets and 0 in between brackets i.e (0)
07825 893217 in this I need to replace leading 0 with + sign and remove spaces
(415) 706 2001 in this replace '(' with + sign and remove ')' and spaces.
'please reply by email' This is the entry in phone number field and I just need to ignore this.
+48.40.23755432 Remove period in phone number
(765) 959-1504 Remove brackets and spaces and hyphen and add + sign in front of number.
7798724250 just need to add + sign in front of number
00 44 (0) 20 7660-4650 Need to remove leading 0 I.E '00' remove spaces and brackets and 0 in between brackets and hyphen and add + sign in front of number
Only leading '0' will be replaced not anyother occourence of '0'
The desired result is +447769146971
Should I use nested REPLACE, CHARINDES, PATINDES for each char I want to replace?
Thanks.