title: Javascript isURL Function
body: <p>I am trying to validate some urls in an application I have and found a function to do so. I can pass the URL and it will return <code>true</code> or <code>false</code> if the url is valid according to the regex.</p>
  
  <p>While this is working for the typical everyday URLs, we have some urls that are on fileshares that we need to allow to pass validation.</p>
  
  <p>I am trying to find out either a good pattern to use for fileshares that can be built into the function below or a jQuery plugin that me include this validation if this already exists.</p>
  
  <pre><code>alert(isURL('\\server-123.somedomain.com\path\to\file.txt')); // Returns False
  
  function isURL(str) {
    var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
    '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+ // domain name
    '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
    '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
    '(\\?[;&amp;a-z\\d%_.~+=-]*)?'+ // query string
    '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
    return pattern.test(str);
  }
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>I don't need it to match that exact path structure in the example shown. I just need a pattern that allowed for file shares in general. My question is specific to the file share structure URL and not the typical http/s/ftp as mentioned as such in the suggested post <a href="https://stackoverflow.com/questions/18364404/javascript-url-validation-regex">here</a></p>