title: Validating IPv4 addresses with regexp
body: <p>I've been trying to get an efficient regex for IPv4 validation, but without much luck. It seemed at one point I had had it with <code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}</code>, but it produces some strange results:</p>
  
  <pre><code>$ grep --version
  grep (GNU grep) 2.7
  $ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' &lt;&lt;&lt; 192.168.1.1
  192.168.1.1
  $ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' &lt;&lt;&lt; 192.168.1.255
  192.168.1.255
  $ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' &lt;&lt;&lt; 192.168.255.255
  $ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' &lt;&lt;&lt; 192.168.1.2555
  192.168.1.2555
  </code></pre>
  
  <p>I did a search to see if this had already been asked and answered, but other answers appear to simply show how to determine 4 groups of 1-3 numbers, or do not work for me.</p>