0

I have the following regex to match / test IP addresses:

 /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|$)){4}/$

So far, so good. Now, I have to create a utility that will test for parts of an ip address string like this:

10.10.10.10 //should pass
10.10.10    //should pass
123.23      //should also pass

I was hoping to recycle my existing code and just put something like {1-4} as the quantifier but so far, it's a no go.

Happydevdays
  • 1,982
  • 5
  • 31
  • 57

0 Answers0