Hi i m having a text having multiple links wrapped inside text...
i want a regex(i m using javascript) which can parse the text and return a array of the links...
for example for the text...
http://www.youtube.com/watch?v=-LiPMxFBLZY
testing
http://www.youtube.com/watch?v=Q3-l22b_Qg8&feature=related
the regex would parse the text and return a array of the links
arr[0] = "http://www.youtube.com/watch?v=-LiPMxFBLZY"
arr[1] = "http://www.youtube.com/watch?v=Q3-l22b_Qg8&feature=related"
i m trying to do so with the code...
var ytre =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig ;
var matches = new Array();
matches = ytre.exec(text);
var jm;
if (matches !=null )
{
for (jm=0; jm<matches.length; jm++)
{
console.log(matches[jm]);
}
}
but its not returning the appropriate results...
please help
thanks