欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

正责表达式

程序员文章站 2022-06-14 20:42:50
...
求助正责表达式
CSS code

([\s\S]*?)/isU' ,$str , $match);
preg_match_all('/href="([\s\S]*?)"/' , $match[1][0], $href );
print_r($href);exit();

function getHtml($url){
        if(function_exists('file_get_contents')){
            $file_contents = file_get_contents($url);
        }
        else{
            $ch = curl_init();
            $timeout = 5;
            curl_setopt ($ch, CURLOPT_URL, $url);
            curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
            $file_contents = curl_exec($ch);
            curl_close($ch);
        }
        return $file_contents;
    }




我要得到分集连接,
但是结果是 连接多了点,要去掉。主要是匹配范围的时候多了点内容,不知道怎么样去掉。还请知点一下。、


我要得到的效果是:

PHP code


            [0] => http://v.youku.com/v_show/id_XMzA0NjA4MjA4.html
            [1] => http://v.youku.com/v_show/id_XMzA0NjA4MjA4.html
            [2] => http://v.youku.com/v_show/id_XMzA2NTYxNDIw.html
            [3] => http://v.youku.com/v_show/id_XMzA2NTYxNDIw.html
            [4] => http://v.youku.com/v_show/id_XMzA4NTQ4NjE2.html
            [5] => http://v.youku.com/v_show/id_XMzA4NTQ4NjE2.html
            [6] => http://v.youku.com/v_show/id_XMzEwNTQyNDM2.html
            [7] => http://v.youku.com/v_show/id_XMzEwNTQyNDM2.html
            [8] => http://v.youku.com/v_show/id_XMzEyNjE3OTAw.html
            [9] => http://v.youku.com/v_show/id_XMzEyNjE3OTAw.html
            [10] => http://v.youku.com/v_show/id_XMzE0NzM4Mjky.html
            [11] => http://v.youku.com/v_show/id_XMzE0NzM4Mjky.html
            [12] => http://v.youku.com/v_show/id_XMzE2OTU0NTgw.html
            [13] => http://v.youku.com/v_show/id_XMzE2OTU0NTgw.html
            [14] => http://v.youku.com/v_show/id_XMzE5MjcyMTY4.html
            [15] => http://v.youku.com/v_show/id_XMzE5MjcyMTY4.html
            [16] => http://v.youku.com/v_show/id_XMzIxNDk2NDcy.html
            [17] => http://v.youku.com/v_show/id_XMzIxNDk2NDcy.html
            [18] => http://v.youku.com/v_show/id_XMzQwMjAxNzgw.html
            [19] => http://v.youku.com/v_show/id_XMzQwMjAxNzgw.html
            [20] => http://v.youku.com/v_show/id_XMzQyNTE2OTA4.html
            [21] => http://v.youku.com/v_show/id_XMzQyNTE2OTA4.html
            [22] => http://v.youku.com/v_show/id_XMzQ0Njk1NDk2.html
            [23] => http://v.youku.com/v_show/id_XMzQ0Njk1NDk2.html
            [24] => http://v.youku.com/v_show/id_XMzQ4NDIyMTI0.html
            [25] => http://v.youku.com/v_show/id_XMzQ4NDIyMTI0.html
            [26] => http://v.youku.com/v_show/id_XMzUxMDI3ODg0.html
            [27] => http://v.youku.com/v_show/id_XMzUxMDI3ODg0.html
            [28] => http://v.youku.com/v_show/id_XMzUzMzUzMjc2.html
            [29] => http://v.youku.com/v_show/id_XMzUzMzUzMjc2.html
            [30] => http://v.youku.com/v_show/id_XMzY2NTk3MTU2.html
            [31] => http://v.youku.com/v_show/id_XMzY2NTk3MTU2.html
            [32] => http://v.youku.com/v_show/id_XMzY5OTM1MzAw.html
            [33] => http://v.youku.com/v_show/id_XMzY5OTM1MzAw.html
            [34] => http://v.youku.com/v_show/id_XMzczNTE4NTA4.html
            [35] => http://v.youku.com/v_show/id_XMzczNTE4NTA4.html
            [36] => http://v.youku.com/v_show/id_XMzAwMDk4NDM2.html
            [37] => http://v.youku.com/v_show/id_XMzAwMDk4NDM2.html
            [38] => http://v.youku.com/v_show/id_XMzA0MTE1MzQw.html
            [39] => http://v.youku.com/v_show/id_XMzA0MTE1MzQw.html
            [40] => http://v.youku.com/v_show/id_XMjcwMDMwMDc2.html
            [41] => http://v.youku.com/v_show/id_XMjcwMDMwMDc2.html
            [42] => http://v.youku.com/v_show/id_XMzA0Njg4MDIw.html
            [43] => http://v.youku.com/v_show/id_XMzA0Njg4MDIw.html
 
正责表达式

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频