4

I am trying to create a validation rule for phone number and using the following regex Validation :

NOT(REGEX( Phone, "^(?=.*?[1-9])[0-9()/\\-\\+\\s\\.\\ ]+$"))

The above regex is working fine if user is manually typing the Phone number. But getting error, if he copy and pasted in the field (Seems like hidden characters in place of spaces).

When I copy pasted the phone number in Notepad++ :

  • Phone Number format: +44 20 3739 5134 (Encode in ANSI)

  • Phone Number format: +44xA020xA03739xA05134 (Encode in UTF-8)

How to resolve this ?

closed as off-topic by Sebastian Kessel, cropredy, Jayant Das, glls, Raul May 22 at 4:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to Salesforce are off-topic here, but can be asked on Stack Overflow." – Sebastian Kessel, cropredy, Jayant Das, glls, Raul
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    probably better in stackoverflow – cropredy May 21 at 19:01
0

That's an editor-dependent problem. 0+00A0 (e.g. xA0 or " ") is a "no-break" space, while 0+0020 (e.g. x20 or " ") is a "normal" space. Depending on where you're copying from, that can definitely cause issues. Technically, \s should also match the no-break space, as far as I'm aware. You may want to open a case with support.

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