0

I am trying to generate a regex which would match the following sequence-

  • +911111111111,+912222222222,+913333333333,+914444444444

It should not allow any other character other than + and numbers

I have tried this->

/^(\+91)\d{10}$/

But it works only for one phone number not for multiple phone numbers

Roma
  • 272
  • 1
  • 12

1 Answers1

1

If

^\+\d{11}$

(a + followed by 11 digits) is not sufficient you'll need to be more specific about what you want to allow and not-allow.

Update following comment: the first two digits are "91" so those can be specified, and then ten further digits:

^\+91\d{10}$
Richard
  • 106,783
  • 21
  • 203
  • 265
  • Every phone number should starts with +91 and followed by 10 digits.And multiple values should get checked – Roma Aug 26 '16 at 10:25
  • @Tushar That requirement is not clear in the question... (but is now) – Richard Aug 26 '16 at 10:28
  • 1
    @Tushar Operative word "guess" (and the whole multiple values requirement seems to be bouncing around). Question is increasingly unclear. – Richard Aug 26 '16 at 10:32
  • Yes. Sorry, I interpreted question wrong and edited it to make it different. OP's requirements is [comma-separated phone numbers](http://stackoverflow.com/questions/39163979/how-can-i-use-regular-expression-for-multiple-values#comment65670787_39164022), please update the answer. – Tushar Aug 26 '16 at 10:36