title: Regular expression for URL
body: <p>I have written regex to validate URL which could be either like</p>
  
  <ul>
  <li><p>example.com</p></li>
  <li><p>www.example.com</p></li>
  <li><p><a href="http://www.example.com" rel="noreferrer">http://www.example.com</a></p></li>
  <li><p><a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></p></li>
  </ul>
  
  <p>All 4 are working</p>
  
  <p>Now, if I am entering in a text like (www.example.com--thisisincorrect), it is allowing me to enter and save into db</p>
  
  <p>The regex that I have used is: </p>
  
  <pre><code>http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?
  </code></pre>
  
  <p>and</p>
  
  <pre><code>([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?
  </code></pre>
  
  <p>Please help!</p>