title: IPv4 regex in bash
body: <p>Does anyone have any suggestions for my regex for IPv4. This does not completely validate an IPv4 address.</p>
  
  <pre><code>IPV4="^(|[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})\|"
  </code></pre>
  
  <p>1.1.1.1 is ok, but 999.1.1.1 also validates :(</p>
  
  <p>Thanks for the input</p>
  
  <p><strong>* UPDATE *</strong></p>
  
  <p>Based on DopeGhoti's input, here is where im at so far. I'm running into issues adding this into my larger regex. I am setting this regex equal to a variable and then combining it with another expression for IPv6 as well. There are a few things that I have added to the regex. For example a (|insert DopeGhoti regex here). This allows me to accept an empty IPv4 address too. I also added a \| at the end because the two addresses being checked by the one big regex are | delimited.</p>
  
  <pre><code>IPV4="^(|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)))\|"
  REGEX="$IPV4$IPV6"
  </code></pre>
  
  <p>This process works with my simplier IPv4 regex. Something in the new regex is breaking it.</p>
  
  <p><strong>* UPDATE *</strong></p>
  
  <p>Ok weird. I tested the following in rubular:</p>
  
  <p><a href="http://rubular.com/r/c6J3sESDyN" rel="nofollow">http://rubular.com/r/c6J3sESDyN</a></p>
  
  <pre><code>^(|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)))\|$
  </code></pre>
  
  <p>This seems to work. Maybe I have another internal issue. Checking now.</p>