ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

USA/Europe telephone "mask" in a text file

(1/1)

IconBoy:
I have exported my contacts into a plain text file and would like to apply a "mask" to certain numbers from certain countries so that they are in a uniform/set pattern e.g:
Below are three USA numbers with different pattern to their numbers.
+1 234 5678901
+13456789012
+1-4567890123
I would like the numbers to end up looking uniformly in the format +c-aaa-nnn-nnnn so the result would be:
+1-234-567-8901
+1-345-678-9012
+1-456-789-0123

Below are three UK numbers with different pattern to their numbers.
+44-7890-123-456
+44 790 123 4567
+44-788-0123456
I would like the numbers to end up looking uniformly in the format +cc-aaaa-nnnnnn so the result would be:
+44-7890-123456
+44-7901-234567
+44-7880-123456

Is there a coding snack that could accomplish this on a text file with numbers in them?
The reason I ask is because my number formatting goes for a loop depending on whether I edit the number in Outlook, on the phone or PDA. If I synchronise, it may be correct on the phone but then the computer contacts either lose some dashes or get spaces added instead of dashes. I know the numbers and dashes don't make a difference on a phone when dialling, but it makes it easier for me to read either on the phone, PDA or computer.
Can anyone help rescue my from my contacts formatting (or lack thereof) nightmare...?

jgpaiva:
Well.. This isn't really a coding snack. I think what you're looking for is a text replacement tool.
A good online option is www.rereplace.com, a site by a fellow DC member, allen.
I personally love Vim, a text editor. But that's kind of too advanced for this task.

Navigation

[0] Message Index

Go to full version