Ask Search:
Alv von der DeckenAlv von der Decken 

Validation rule for phone number format (regex)

I need your help in order to create a validation rule for telephone number to following format (german phone number system):

"+49", than "-" followed by 3 to 4 digits (0-9), than forced "-" followed by 3 to x digits digits (0-9), possible but not forced "-" followed by 1 to x digits (0-9).


Can anyone create a regex for me?

Thank you very much in advance.
Eric PraudEric Praud

try this:
NOT(OR(REGEX( Phone , "[+49]{3}-[0-9]{3}-[0-9]{3}"), 

REGEX( Phone , "[+49]{3}-[0-9]{3}-[0-9]{7}"), 
REGEX( Phone , "[+49]{3}-[0-9]{4}-[0-9]{9}-[0-9]{1}"), 
REGEX( Phone , "[+49]{3}-[0-9]{4}-[0-9]{3}-[0-9]{9}")))

Let me know if this works, thanks
Alv von der DeckenAlv von der Decken
Hello and thanks a lot.

I changed to following and it works just fine:

OR( LEN(  Phone  ) = 0,
REGEX(Phone, "[+49]{3}-[1-9]{1}[0-9]{2,3}-[0-9]{3,9}") ,
REGEX(Phone, "[+49]{3}-[1-9]{1}[0-9]{2,3}-[0-9]{3,9}-[0-9]{1,9}"))))
Mantrala Ranjeeth kumarMantrala Ranjeeth kumar
@Eric Praud can u please explain me the formula how it works ...? 

step wise :) 

im a newbie having the same problem
Cloud UrsaCloud Ursa
This is a great question and one we have come across a lot. It inspired us to write an app called RingsTrue which will help with this type of issue.

RingsTrue will launch soon on the @AppExchange and will run through all of your telephone records in Salesforce, tidy them, validate them, and then check whether they are in service or not.

If you still need any help validating your phone records please check it out.

#ringstrue #telephonevalidation 
Aarya TiwaryAarya Tiwary
If the Format is +19042380274 ??
Then what is the format(regex)
Saifullah SaifiSaifullah Saifi
REGEX( phone , "[+19]{3}[0-9]{3} [0-9]{3} [0-9]{3}")