$str = <<<TEXT 如下类似网址: https://v.qq.com/iframe/player.html?vid=j00169ib5er&tiny=0&auto=0 https://v.qq.com/iframe/player.html?vid=x00243heka3&tiny=0&auto=0 TEXT; preg_match_all("#\?vid\=(.+?)&#",$str,$arr); echo '<pre>'; var_dump($arr[1]); echo '</pre>'; /* array (size=2) 0 => string 'j00169ib5er' (length=11) 1 => string 'x00243heka3' (length=11) */
方法二; $str="https://v.qq.com/iframe/player.html?vid=j00169isdfsdsb5er&tiny=0&auto=0"; preg_match_all("/vid=([\s\S]*?)&/",$str,$arr); print_r($arr);
如下类似网址:
https://v.qq.com/iframe/player.html?vid=j00169ib5er&tiny=0&auto=0
https://v.qq.com/iframe/player.html?vid=x00243heka3&tiny=0&auto=0
怎么用正则取出红色位置的参数?
即可以得到vid=和&中间的参数,谢谢!