preg_match troubles

bonabona

New Member
I am trying to match a Youtube URL with regex to see if it is valid. This is my code:\[code\]if(preg_match('\bhttp://youtube.com/watch\?v=.*\b', $link)){ echo "matched youtube";}\[/code\]But I'm getting an error:\[code\]Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in C:\xampp\htdocs\ajax\youtube.php on line 22\[/code\]I'll admit I am a complete novice to regular expressions and I don't understand them much but I am trying to learn as I do this. I made the above regex using this online regex tool:http://gskinner.com/RegExr/and it works there. So what am I doing wrong and is there a better way to validate a youtube URL?Thanks. :)
 
Back
Top