How to remove all punctuation EXCEPT dashes?

Ask a Question related to FileMaker, Design and Development.

  1. #1

    Default How to remove all punctuation EXCEPT dashes?

    I need to standardize phone numbers that are entered many different ways. I
    can remove all punctuation then use left/middle/right functions to break
    apart the number and make a calculated version but is there an easier way?

    Can I remove parentheses, spaces, periods, and slashes from a phone number
    field without also removing the dashes?


    (216)555-1212 into 216-555-1212
    (216) 555-1212 into 216-555-1212
    (216) 555-1212 into 216-555-1212
    (216)-555-1212 into 216-555-1212
    (216)-555-1212 into 216-555-1212
    216.555.1212 into 216-555-1212
    216/555-1212 into 216-555-1212

    and not

    2165551212

    Any help would be GREATLY appreciated

    TIA


    Guest

  2. Similar Questions and Discussions

    1. #23325 [Com]: PHP can't connect if db name has dashes
      ID: 23325 Comment by: chris at sugarcrm dot com Reported By: fritz at lateral dot net Status: No Feedback Bug...
    2. Strip Dashes and Spaces from Credit Card
      Hi, Does anyone know an easy way to strip dashes and spaces (or any other characters for that matter) from a credit card. I want to allow users...
    3. creating dashes to meet in corners??
      is there a way I can apply dashes to a shape drawn but have the dashes always meet in the corners of the shape? I Have played around with the...
    4. format form field to include dashes
      Hi... thought I'd ask this in a separate post. I'm creating a basic formmail form, and my client has asked me to have the phone number reformat...
    5. Dots and Dashes
      Thanks Kim, I just needed those! Coen Kim Cavanaugh wrote: --
  3. #2

    Default Re: How to remove all punctuation EXCEPT dashes?

    The trick is to take everything but the numbers out using nested Substitute
    functions (I'll call this CalcA:

    Substitute(Substitute(Substitute(Substitute(Substi tute(Substitute(Number,
    "(", ""), ")", ""), ".", ""), "-", ""), " ", ""), "/", "")

    Then put the dashes back in:

    Left(CalcA, 3) &"-" & Middle(CalcA, 4, 3) & "-" & Right(CalcA, 4)

    Final calc:

    Left(Substitute(Substitute(Substitute(Substitute(S ubstitute(Substitute(Numbe
    r, "(", ""), ")", ""), ".", ""), "-", ""), " ", ""), "/", ""), 3) &"-" &
    Middle(Substitute(Substitute(Substitute(Substitute (Substitute(Substitute(Num
    ber, "(", ""), ")", ""), ".", ""), "-", ""), " ", ""), "/", ""), 4, 3) & "-"
    &
    Right(Substitute(Substitute(Substitute(Substitute( Substitute(Substitute(Numb
    er, "(", ""), ")", ""), ".", ""), "-", ""), " ", ""), "/", ""), 4)

    Bridget Eley

    in article ZDc%a.25617$Vx2.11488935@newssvr28.news.prodigy.co m,
    [email]mojotogo@sbcglobal.net[/email] at [email]mojotogo@sbcglobal.net[/email] wrote on 16/8/03 7:54 AM:
    > I need to standardize phone numbers that are entered many different ways. I
    > can remove all punctuation then use left/middle/right functions to break
    > apart the number and make a calculated version but is there an easier way?
    >
    > Can I remove parentheses, spaces, periods, and slashes from a phone number
    > field without also removing the dashes?
    >
    >
    > (216)555-1212 into 216-555-1212
    > (216) 555-1212 into 216-555-1212
    > (216) 555-1212 into 216-555-1212
    > (216)-555-1212 into 216-555-1212
    > (216)-555-1212 into 216-555-1212
    > 216.555.1212 into 216-555-1212
    > 216/555-1212 into 216-555-1212
    >
    > and not
    >
    > 2165551212
    >
    > Any help would be GREATLY appreciated
    >
    > TIA
    >
    >
    Bridget Eley Guest

  4. #3

    Default Re: How to remove all punctuation EXCEPT dashes?

    How about this?

    Left( Abs( TextToNum( Phone ) ) , 3 ) & "-" &
    Middle( Abs( TextToNum( Phone ) ) , 1 , 3 ) & "-" &
    Right( Abs( TextToNum( Phone ) ) , 4 )

    Shadenfroh


    <mojotogo@sbcglobal.net> wrote in message
    news:ZDc%a.25617$Vx2.11488935@newssvr28.news.prodi gy.com...
    > I need to standardize phone numbers that are entered many different ways.
    I
    > can remove all punctuation then use left/middle/right functions to break
    > apart the number and make a calculated version but is there an easier way?
    >
    > Can I remove parentheses, spaces, periods, and slashes from a phone number
    > field without also removing the dashes?
    >
    >
    > (216)555-1212 into 216-555-1212
    > (216) 555-1212 into 216-555-1212
    > (216) 555-1212 into 216-555-1212
    > (216)-555-1212 into 216-555-1212
    > (216)-555-1212 into 216-555-1212
    > 216.555.1212 into 216-555-1212
    > 216/555-1212 into 216-555-1212
    >
    > and not
    >
    > 2165551212
    >
    > Any help would be GREATLY appreciated
    >
    > TIA
    >
    >

    Shadenfroh Guest

  5. #4

    Default Re: How to remove all punctuation EXCEPT dashes?

    In reply to s5e%a.22612$vo2.6865@newsread1.news.atl.earthlink. net on 8/15/03
    4:33 PM by Shadenfroh [email]shadenfroh@yahoo.com[/email]:

    Slightly Modified

    Left( Abs( TextToNum( Text ) ) , 3 ) & "-" &
    Middle( Abs( TextToNum( Text ) ) , 4 , 3 ) & "-" &
    Right( Abs( TextToNum( Text ) ) , 4 )

    Lee

    :)
    > How about this?
    >
    > Left( Abs( TextToNum( Phone ) ) , 3 ) & "-" &
    > Middle( Abs( TextToNum( Phone ) ) , 1 , 3 ) & "-" &
    > Right( Abs( TextToNum( Phone ) ) , 4 )
    >
    > Shadenfroh
    >
    >
    > <mojotogo@sbcglobal.net> wrote in message
    > news:ZDc%a.25617$Vx2.11488935@newssvr28.news.prodi gy.com...
    >> I need to standardize phone numbers that are entered many different ways.
    > I
    >> can remove all punctuation then use left/middle/right functions to break
    >> apart the number and make a calculated version but is there an easier way?
    >>
    >> Can I remove parentheses, spaces, periods, and slashes from a phone number
    >> field without also removing the dashes?
    >>
    >>
    >> (216)555-1212 into 216-555-1212
    >> (216) 555-1212 into 216-555-1212
    >> (216) 555-1212 into 216-555-1212
    >> (216)-555-1212 into 216-555-1212
    >> (216)-555-1212 into 216-555-1212
    >> 216.555.1212 into 216-555-1212
    >> 216/555-1212 into 216-555-1212
    >>
    >> and not
    >>
    >> 2165551212
    >>
    >> Any help would be GREATLY appreciated
    >>
    >> TIA
    >>
    >>
    >
    >
    Lee Smith Guest

  6. #5

    Default Re: How to remove all punctuation EXCEPT dashes?

    Oops. Didn't notice that because of the previous error you pointed out. Try
    this (don't have time to test it myself at the moment).

    Left( Substitute ( Abs( TextToNum( Text ) ) , "." , "" ) , 3 ) & "-" &
    Middle( Substitute ( Abs( TextToNum( Text ) ) , "." , "" ), 4 , 3 ) & "-"
    &
    Right( Substitute ( Abs( TextToNum( Text ) ) , "." , "" ) , 4 )

    Shadenfroh

    "Lee Smith" <lee@pacific.net> wrote in message
    news:BB62D104.2CD57%lee@pacific.net...
    > In reply to BB62C764.2CD50%lee@pacific.net on 8/15/03 5:22 PM by Lee Smith
    > [email]lee@pacific.net[/email]:
    >
    > I just noticed that this calculation breaks on the one that has periods.
    >
    > 216.555.1212
    >
    > ends up
    >
    > 216-.55-1212
    >
    > Lee
    >
    >
    > > In reply to s5e%a.22612$vo2.6865@newsread1.news.atl.earthlink. net on
    8/15/03
    > > 4:33 PM by Shadenfroh [email]shadenfroh@yahoo.com[/email]:
    > >
    > > Slightly Modified
    > >
    > > Left( Abs( TextToNum( Text ) ) , 3 ) & "-" &
    > > Middle( Abs( TextToNum( Text ) ) , 4 , 3 ) & "-" &
    > > Right( Abs( TextToNum( Text ) ) , 4 )
    > >
    > > Lee
    > >
    > > :)
    > >> How about this?
    > >>
    > >> Left( Abs( TextToNum( Phone ) ) , 3 ) & "-" &
    > >> Middle( Abs( TextToNum( Phone ) ) , 1 , 3 ) & "-" &
    > >> Right( Abs( TextToNum( Phone ) ) , 4 )
    > >>
    > >> Shadenfroh
    > >>
    > >>
    > >> <mojotogo@sbcglobal.net> wrote in message
    > >> news:ZDc%a.25617$Vx2.11488935@newssvr28.news.prodi gy.com...
    > >>> I need to standardize phone numbers that are entered many different
    ways.
    > >> I
    > >>> can remove all punctuation then use left/middle/right functions to
    break
    > >>> apart the number and make a calculated version but is there an easier
    way?
    > >>>
    > >>> Can I remove parentheses, spaces, periods, and slashes from a phone
    number
    > >>> field without also removing the dashes?
    > >>>
    > >>>
    > >>> (216)555-1212 into 216-555-1212
    > >>> (216) 555-1212 into 216-555-1212
    > >>> (216) 555-1212 into 216-555-1212
    > >>> (216)-555-1212 into 216-555-1212
    > >>> (216)-555-1212 into 216-555-1212
    > >>> 216.555.1212 into 216-555-1212
    > >>> 216/555-1212 into 216-555-1212
    > >>>
    > >>> and not
    > >>>
    > >>> 2165551212
    > >>>
    > >>> Any help would be GREATLY appreciated
    > >>>
    > >>> TIA
    > >>>
    > >>>
    > >>
    > >>
    > >
    >

    Shadenfroh Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139