title: Match all URLs in string and return in array in JavaScript
body: <p>For example, I have the following string:</p>
  
  <pre><code>var string = 'watch this video http://vimeo.com/8122132 and then see this picture http://www.flickr.com/photos/pmorgan/32606683/';
  </code></pre>
  
  <p>I wish to find all the valid URLs and place them in an array, done in JavaScript (and jQuery), so in this case:</p>
  
  <pre><code>url[0] = http://vimeo.com/8122132
  url[1] = http://www.flickr.com/photos/pmorgan/32606683/
  </code></pre>
  
  <p>For now, I can only match one URL, but I wish to match all. This is what I have:</p>
  
  <pre><code>geturl = new RegExp("(^|[ \t\r\n])((ftp|http|https|gopher|mailto|news|nntp|telnet|wais|file|prospero|aim|webcal):(([A-Za-z0-9$_.+!*(),;/?:@&amp;~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&amp;~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))");
  var url = geturl.exec(string);
  $('#urls').html(url[0]);
  </code></pre>
  
  <p>Trust me, putting url[1], url[2], etc. doesn't work :(</p>
  
  <p>Any ideas?</p>