title: regex ip address with optional port and localhost
body: <p>I have the following regular expression to detect an ip address (ipv4) with an optional port,
  I would like also to support the host <code>localhost</code>. I am not very familiar with regex... how to update it so <code>localhost</code> is also valid?</p>
  
  <pre><code>/\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?::\d{0,4})?\b/
  </code></pre>