title: C# Regex Port Validation 49152 to 65535
body: <p>After reading about ports and suggested ports I discovered that to comply with Internet Assigned Numbers Authority (IANA) recommendations for private ports you should only use ports from 49152 to 65535. As such I have attempted a regex pattern to check that the user has entered a port within that range. I have pieced this together with a great headache I had to read a lot of tutorials to get this far regex patters are really not human friendly. Basically I am looking for someone with more knowledge than me to verify that it is correct. My testing seems to indicate it but maybe I am missing something I just wanted to make sure.</p>
  
  <pre><code>string pattern = @"^(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|5\d{4}|49[2-9]\d\d|491[6-9]\d|4915[2-9])$";
  </code></pre>
  
  <p>Regards!</p>