Let\'s take these URLs as an example:
Instead of regex. I hightly recommend parse_url() and parse_str():
$url = "http://www.youtube.com/watch?v=8GqqjVXhfMU&feature=youtube_gdata_player"; parse_str(parse_url( $url, PHP_URL_QUERY ), $vars ); echo $vars['v'];
Done