Regex restrictions


I’d like to add some restrictions under phone number being filled.

  1. The phone number should always start with a 961
  2. The phone number should always be 8 characters after 961
  3. If fist digit of phone number after 961 starts with a 0 then disregard the 0. (hence allow 7 digits after 961)

I have what I need for steps # 1 & 2: regex(.,‘^961[0-9]{8}$’)
However, my only issue is adding step # 3 to it.

Eg: 9613000000 -Accepted
96103000000 -Not Accepted

Please advise,

Thank you.

I was able to solve this using regex(.,‘^961[1-9]{1}[0-9]{6,7}$’)

Thank you !


@mireillejazi, :clap: :heart: :partying_face: Thank you for sharing the solution with the entire community!