JavaScript RegEx Pattern for URLs

Here is a simple JavaScript RegEx pattern for extracting any URL that begins with htttp:

<script type="text/javascript">

// example string, looks like a tweet to me 🙂
var str="Awesome resources for HTML5! #HTML5";

// could also be written as:
// var regexUrl = new RegExp("http.[^\s]+", "gi");
var regexUrl=/http.[^\s]+/gi;

// if a match is found, the return type is an array of matches

// output of above line of code:

Comments (0)