title: regular expression checking valid hostname port
body: <p>I've searched thru various websites and here for one that works but none do.</p>
  
  <p>I need a regex that validates a game server hostname is correct format.</p>
  
  <p>Example:</p>
  
  <pre><code>gost.gflclan.com:27015
  </code></pre>
  
  <p>And also the normal ip:port</p>
  
  <pre><code>103.18.138.27:27015
  </code></pre>
  
  <p>The hostname version can also have numbers in the subdomain or main part. And always has 5 numbers in port on both.</p>
  
  <p>I've currently got this but it only works for the ip:port and not the hostname one.</p>
  
  <pre><code>([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{5})|([a-z].[a-z].[a-z]:[1-9]{5})
  </code></pre>
  
  <p>Thanks if you can help.</p>