DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: USA/Europe telephone "mask" in a text file  (Read 5,187 times)

IconBoy

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 35
USA/Europe telephone "mask" in a text file
« on: March 25, 2007, 09:11 PM »
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...?
« Last Edit: March 25, 2007, 09:15 PM by IconBoy »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: USA/Europe telephone "mask" in a text file
« Reply #1 on: March 25, 2007, 10:25 PM »
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.

Original address: https://www.donationcoder.com/forum/index.php?topic=7889.0