title: Lua function check if ipv4 or ipv6 or string
body: <p>I'd like to have a function that I can pass a whitespace trimmed string to and it will return  <br/>0 for error (not a string) 1 for ipv4 2 for ipv6 3 for a string thats not an ip.  <br/></p>
  
  <p>Ipv6 has these rules:  <br/></p>
  
  <p>Ipv6 is represented by 8 groups of 16-bit hexadecimal values separated by colons (:)  <br/>
  The hexadecimal digits are case-insensitive  <br/>
  Abbreviation rules:  <br/>
      1: Omit leading zeroes in a 16-bit value  <br/>
      2: Replace one or more groups of consecutive zeroes by a double colon  <br/></p>
  
  <p>wiki example showing 3 ways that are all the same ipv6:  <br/></p>
  
  <pre><code>fe80:0000:0000:0000:0202:b3ff:fe1e:8329
  fe80:0:0:0:202:b3ff:fe1e:8329
  fe80::202:b3ff:fe1e:8329 
  </code></pre>
  
  <p>I'm reasonably sure for ipv4 you just check for three . then check the string is all  <br/> numbers and the .'s are counted as numbers and the last check for just a string  <br/> would be at the end of an if statement so if its not ipv4/6 and its a string then   <br/>it returns 3  <br/></p>