• Anmol Panchal
  • NEWBIE
  • 5 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have this code in workflow rule which aims to remove / , . , - , and stores in a proper format (xxx) xxx-xxxx US phone no. But i am facing difficulty in removing / sign by a blank space.

IF(
 LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( Phone , ".", ''),"/", ""),"-",""),"+",""))= 11,
 "("&
 MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( Phone , ".", ''),"/", ""),"-",""),"+",""),2,3)&
 ") "&
 MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( Phone , ".", ''),"/", ""),"-",""),"+",""),5,3)&
 "-"&
 MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( Phone , ".", ''),"/", ""),"-",""),"+",""),8,4),
 "("&
 MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( Phone , ".", ''),"/", ""),"-",""),"+",""),1,3)&
 ") "&
 MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( Phone , ".", ''),"/", ""),"-",""),"+",""),4,3)&
 "-"&
 MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE( Phone , ".", ''),"/", ""),"-",""),"+",""),7,4)
)
I would like to make sure all phone numbers are updated to conform to this format:

(xxx) xxx-xxxx

I tried to write a workflow rule to address this as follows:

NOT (
   REGEX( HomePhone , "([0-9]{3})[0-9]{3}-[0-9]{3}")
)

However, I get the following syntax error: "Error: Function REGEX may not be used in this type of formula"
Is there a way to use REGEX here?  Is there a better way to go about this?

I