regex - Need Regular Expression to Only to have + sign and digits only min 10 max 15 -


i need regex validate phone numbers:

conditions:

  1. it may have + sign @ beginning (optional)
  2. then followed digits
  3. minimum 10 digits
  4. maximum 15 digits

thanks

you can try one:

^\+?\d{10,15}$ 

explanation:

  1. ^ marks start of string
  2. \+? - \ escapes + sign , ? makes optional
  3. \d digit between 0-9
  4. {10,15} means minimum 10 digit , 15 means maximum 15
  5. $ marks end of string

p.s: solomon island has 5 digit phone numbers. country code can 8 digits

demo


Comments