-2

I am having a hard time understanding regex. I want to validate Nepali phone numbers using regex.

+977-98########
+977-97########
+977-01-#######

+977 98########
+977 97########
+977 01#######

98########
97########

01-#######
01#######

I would be very thankful if someone helps me in this :)

anubhava
  • 713,503
  • 59
  • 514
  • 593
Prakash Dahal
  • 3,214
  • 2
  • 8
  • 19

1 Answers1

3

Try this:

(?:\+977[- ])?\d{2}-?\d{7,8}

See Demo

Alireza
  • 2,011
  • 1
  • 5
  • 18