0
REGEX( {!Phone} , "((^[?+\+\s]|^[\d]?)([\s\-\.]?)([\d]{1,3})([\s\-\.\(]*)([\d]{3})([\s\-\.\)]*)([\d]{3})([\s\-\.]*)([\d]{4})$)" )

Phone (Screen Component) - The formula expression is invalid: Syntax error

What is wrong here? I copy paste ((^[?+\+\s]|^[\d]?)([\s\-\.]?)([\d]{1,3})([\s\-\.\(]*)([\d]{3})([\s\-\.\)]*)([\d]{3})([\s\-\.]*)([\d]{4})$) in regex checker and it seems ok, but in salesforce syntax error?

2

You have to escape your backslashes. Anywhere you have one backslash (\), replace it with two (\\).

1
  • REGEX( {!Phone} , "((^[?+\\+\\s]|^[\\d]?)([\\s\\-\\.]?)([\\d]{1,3})([\\s\\-\\.\\(]*)([\\d]{3})([\\s\\-\\.\\)]*)([\\d]{3})([\\s\\-\\.]*)([\\d]{4})$)" ) As you mention I replace all \ with \\ and it worked. thank you. – SFDX TubeCube Aug 14 '19 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.