Reply To: Removing parenthesis and dashes from phone numbers

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Removing parenthesis and dashes from phone numbers Reply To: Removing parenthesis and dashes from phone numbers

#59688
Charlie Bursell
Participant

    It would be much safer to it on a field by field basis.  If done that way:

    set phoneNo [string map “( {} } {} – {}” $phoneNum]

    set ssan [string map “- {}” $ssan]

    If you want to take a chance that the patterns occur only in SSN and Phone numbers, you could do a proc like

    # replace all pattern (###)###-##### with ##########

    regsub -all — {((d{3}))(d{3})-(d{4})} $phoneNum {123} newNum

    # replace all pattern ###-##-#### with #########

    regsub -all — {(d{3})-(d{2})-(d{4})} $ssn {123} newSSN