locked
US and international phone numbers RRS feed

  • Question

  • Ok, so I know I can use this to format the US phone numbers:

    ="Phone: " +System.Text.RegularExpressions.Regex.Replace(iif(IsNothing(Fields!MAIN_PHONE.Value),"N/A",Fields!MAIN_PHONE.Value), "(\d{3})[ -.]*(\d{3})[ -.]*(\d{4})", "($1) $2-$3")

    However, I have been given the US and Internation phone numbers in the same field. So, how do I write code to format the phone number for either format?

    Any help is appreciated!
    Thursday, March 26, 2009 3:23 PM

All replies

  • Ok, I am using this...

    =IIF(left(Fields!MAIN_PHONE.Value,1) <> "+","Phone: " +System.Text.RegularExpressions.Regex.Replace(iif(IsNothing(Fields!MAIN_PHONE.Value),"N/A",Fields!MAIN_PHONE.Value), "(\d{3})[ -.]*(\d{3})[ -.]*(\d{4})", "($1) $2-$3") , "Phone: " + Fields!MAIN_PHONE.Value)

    so if there is a + sign then leave the field as is otherwise format the field for US phone numbers.

    (555) 499-1212.

    However, now I am seeing trailing zeros for the international numbers.

    Phone: +33149777548
     0 00 00 00 00

    Any ideas how to remove the trailing zeros?

    Thursday, March 26, 2009 3:45 PM