Reputation: 5148
I am trying to find and match from video links like this :
So the last part which is HTFeu is needed and with bellow code I am verify the video link but I have problem with regExp statement.
var vurl = jQuery("#y_link").val();
var regExp = /^.*((aparat.com\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = vurl.match(regExp);
if (match && match[7].length == 6) {}
else {
alert("video link is not valid");
return false;
}
Upvotes: 0
Views: 56
Reputation: 6619
Try this regex for the end part to get
var regex = \/v\/\w*;
if(regex.indexOf("/") > -1){
alert(regex.split('/')[2])
}
or you can try without regex
var string = "http://www.aparat.com/v/HTFeu";
if(string.indexOf("/") > -1){
alert(string.split('/')[-1])
}
Upvotes: 1
Reputation: 1263
You can use a great tool like Rubular to try your regex: http://rubular.com/
This is meant for regex in Ruby but hey are almost the same than in javascript.
Upvotes: 0