我可以帮助调试这个正则表达式吗?

时间:2013-03-14 19:00:46

标签: php regex youtube

这是我得到的错误preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 77

这就是业务:

$youtubeIdPattern = "#(?<=(?:v|i)=)[a-zA-Z0-9-]+(?=&)|(?<=(?:v|i)\/)[^&\n]+|(?<=embed\/)[^\"&\n]+|(?<=??(?:v|i)=)[^&\n]+|(?<=youtu.be\/)[^&\n]+#";
                $youtubeIdMatch = array();
                if ( isset( $regexMatch[0] ) && $regexMatch[0] != "" ) :
                    preg_match($youtubeIdPattern,$regexMatch[0],$youtubeIdMatch);
                endif;

仅供参考,我们正尝试从Youtube网址中获取视频ID。

2 个答案:

答案 0 :(得分:3)

这是??,布莱恩!

如果您想匹配文字?,则需要转发

?

答案 1 :(得分:3)

你连续有2个问号的地方(?=??(? - 你的意思是文字问号(\?)吗?