0

I'm trying to create a validation rule for our phone numbers. Every number has 3 parts:

  • Country Code (numerical, min. 1 digit, max 3 digits, starts with '+')
  • Area Code (numerical, min. 1 digit, max 4 digits, cannot start with 0)
  • Number (numerical, no digit limit, cannot start with 0)

Examples:

+32 12 1234567

+359 123 1234567899

I checked many examples, unfortunately I cannot find out how to say that every parts' digit numbers should be variable (country code could have min. 1 and max. 3 digits) and cannot start with 0

1

The solution I just came with:

NOT(REGEX(Phone,"[+]\d\d?\d?\s\d\d?\d?\d?\s\d+"))

Explaination:

[+] (the obligatory "+" at the beginning)

Country Code:

\d\d?\d? (min 1 digit, max. 3 digits)

\s (whitespace)

Area Code

\d\d?\d?\d? (min 1 digit, max. 4 digits)

\s (whitespace)

Number

\d+ (min 1 digit)

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.