title: How to create custom valid Url Regex
body: <p>I am trying to create a regex for first time for the URL having following conditions:</p>
  <ol>
  <li>Starts with or without the www</li>
  <li>Do not starts with http:// or https://</li>
  <li>Allowed special characters are: hyphen (-) and dot (.)</li>
  <li>Ends with a TLD like: .com, .io, .co.in, etc.</li>
  </ol>
  <p>Some of the examples for reference:</p>
  <p><strong>Valid:</strong></p>
  <pre><code>xyz.com
  xyz-px.com
  www.xyz.com
  abc.xyz.px.io
  www.abc.xyz.px.io
  </code></pre>
  <p><strong>Invalid:</strong></p>
  <pre><code>xyz-.com
  xy_pm.com
  http://xyz.io
  https://xyz.io
  http://www.pm.xyz
  xy@pzzzz.com
  xyz.io$#
  www.xy
  xyz.io-
  </code></pre>
  <p>I have created a regex</p>
  <p><code>/(^(?!https|http)?:\/\/(www\.?)[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,})/gi</code></p>
  <p>But it is not working as desired.</p>