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