<p>How can I determine if a string is an IP address? Either <em>IPv4</em> or <em>IPv6</em>?</p>

<p>What is the least and most number of characters?</p>

<p>I assume this would be a <strong>regex</strong> answer.</p>

For IPv4 you can use this regular expression.
```
```
\b(?:(?: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]?)\b
```
```
It looks quite complex but it works by limiting each quad to the numbers 0-255.