Adding a mask to a 10 digit phone number

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Adding a mask to a 10 digit phone number

  • Creator
    Topic
  • #52525
    Tom Arrowsmith
    Participant

      I know how to remove parenthesis, spaces and dashes from phone numbers that need them removed for downstreams – I utilize an “xlt_string_map” proc from within an xlate (provided by Jim Koslovsky) and it works great….

      Now, I have the opposite problem. I am getting a 10 digit phone number in the format xxxxxxxxxx from the sending system – and must now reformat the number into a (xxx) xxx-xxxx format (note the space after the closing parenthesis for the area code).

      I’m hoping someone may have a tcl proc that can be run from within an xlate – or even a few lines of tcl coding that can be directly pasted into the xlate – that will acomplish this.

      Can anyone help me out?

      Thanks!

      Tom

    Viewing 2 reply threads
    • Author
      Replies
      • #74555
        Steve Carter
        Participant

          Assuming that the phone number is always 10 digits:

          hcitcl>set num 5555551212

          5555551212

          hcitcl>regsub {(d{3})(d{3})(d{4})} $num {(1) 2-3} newNum

          1

          hcitcl>puts $newNum

          (555) 555-1212

          Hope this helps.

          Steve

        • #74556
          Tom Arrowsmith
          Participant

            I tried pasting

          • #74557
            Steve Carter
            Participant

              Use this in the xlate:

              set num [lindex $xlateInVals 0]

              regsub {(d{3})(d{3})(d{4})} $num {(1) 2-3} newNum

              set xlateOutVals $newNum

              This should take care of it.

              Steve

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.