title: jQuery number of URL validation
body: <p>I need a validation that a string cannot contain more than 1 URL. Maximum length of string may be 500 characters. Is there any efficient way to calculate number of URL with less time complexity?
  Thanks.</p>
  
  <p>Here's what I've currently tried:</p>
  
  <pre><code>var count = 0; 
  var urlArray = urlstring.split(" "); 
  
  $.each( urlArray, function( i, val ) { 
      if(val != "") { 
          var flag = val.match(/^((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=‌​&amp;%@!\-\/]))?$/); 
  
          if(flag) {
              count++; 
          } 
      } 
  });
  </code></pre>