Forum Stats

  • 3,678,237 Users
  • 7,787 Discussions
  • 13,078 Comments

Discussions

Normalizing phone numbers with Contact Washing Machine and RegEx

We are trying to take phone numbers on our contact records and making sure they are only numbers (no dashes, no parentheses, etc.).

Trying to use the Contact Washing Machine app to do a find and replace on the phone number field, but struggling with the Regex to use in the find and replace entries in the configuration.

I'm a relative newbie on RegEx, and I've done some research, but not had much luck.

TIA

Comments

  • Greg_W
    Greg_W Posts: 18 Silver Badge

    @User_VS7ZW It may be easier than you might expect... but as with everything RegEx it really depends on how strict you want to be. In the simplest execution you would use the RegEx Replace option.

    Set Regular Expression to find: [^0-9]+

    and leave Regular Expression to replace blank

    This will only select numbers, removing everything else, so there's no need to define the replace! If you wanted to extract () and replace them with hyphens etc then it gets a little more complex.


    Hope that helps!

  • Michael Hartmann
    Michael Hartmann Posts: 2 Green Ribbon

    I think I tried that @Greg_W but when I tried to leave the replace as blank I don't think I was able to do that.

    I found another RegEx that extracted the numbers in groups and I just used that to then select only the numbers from area code, exchange and the remainder.

  • Joanna S
    Joanna S Posts: 1 Blue Ribbon

    Hi @Greg_W,

    I tried your suggestion and it worked for my application!

    Thanks