2013-03-14 64 views
0

這裏的錯誤,我得到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。

回答

3

如果你連續有2個問號(?=??(? - 你的意思是說它是一個字面問號(\?)?

+0

這正是它出了什麼問題。逃脫了?它的工作。感謝您的發現。 – 2013-03-14 19:15:50

3

這是布賴恩的??

?如果您想匹配文字?,則需要轉義。

相關問題