Regex to match Youtube URL's

K.O.X

New Member
I am trying to validate a Youtube URL using regex:\[code\]preg_match('~http://youtube.com/watch\?v=[a-zA-Z0-9-]+~', $videoLink)\[/code\]It kind of works, but it can match URL's that are malformed. For example, this will match ok:\[code\]http://www.youtube.com/watch?v=Zu4WXiPRek\[/code\]But so will this:\[code\]http://www.youtube.com/watch?v=Zu4WX
 
Back
Top