standardize international phone no. code using only regex
- by DarkFox
Sipdroid on Android has a search & replace method, that uses regex.
I'm trying to use it to make sure all outgoing calls has a country code in the format 00XX
I also want it to put 0045 in front of the number, if no country code is present.
The first one, I have solved, but I can't figure out how to do the second thing.
Search:
\A(((\+)(\d{2})?)|(00(\d{2})?)|)((\d|\s)+)\Z
Replace:
00$4$6$7
I'm using http://www.regexplanet.com/simple/index.html to test it, with the test strings: "12345678", "+4512345678" and "004512345678"
They should all return "004512345678".