I\’m trying to format some phone numbers with regex p. The phone numbers i have stored are of diffrent length and all phone numbers have their country codes. Lets say a number looks like this: 00460708186681. I want that one to be formatted as: +46 (0)708-18 66 81. The first three groups are easy:
/00([\\d]{2})([\\d]{1})([\\d]{3})/
Because the beginning of the number will always be the same. It\’s the last part where i dont know the length of the remaining chars (and i want them to be divided into groups of two).





Rating:
The post regex – Phone number format javascript appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/regex-phone-number-format-javascript.html
No comments:
Post a Comment