php - 这个问题困扰很久 strpos 遇到https
迷茫
迷茫 2017-04-11 09:06:41
0
2
997
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (2)
迷茫
$url = 'https://v.qq.com/x/cover/ucr5uujf5ds5d8r/p0022qljz7v.html'; $data = end(explode('/', $url)); list($fileName) = explode('.', $data); echo $fileName;
    大家讲道理
    var htmltext = "asdfjasdajfkasladafdsdf"; //捕获组表达式 var zhengze = /\/>]*src=[\'\"]https\:\/\/[^\'\"]+\/([^\'\"\/]+\.(?:html|htm))[\'\"][^>\/>]*(?:>|\/>)/gi; //验证表表达式 var zhengzes = /\/>]*src=[\'\"]https\:\/\/[^\'\"]+\/([^\'\"\/]+\.(?:html|htm))[\'\"][^>\/>]*(?:>|\/>)/i; if (zhengzes.test(htmltext)) { var shuchu = htmltext.match(zhengze); var zifu = ""; var ss = ""; console.log(shuchu); for (var i = 0; i < shuchu.length; i++) { //当符合结果只有一个时,并且正则表达式中包含捕获组时 exec与match的执行结果相同【第一部分为匹配字符串】【第二部分为捕获组字符串】 zifu += zhengzes.exec(shuchu[i])[1] + ","; // zifu += shuchu[i].match(zhengzes)[1] + "\r\n"; } console.log(zifu); // return zifu.substring(0, zifu.length - 1); } else { console.log("false"); // return '0'; }

    用javascript写的,但是正则是一样的你可以替换一下试试
    我这输出结果为 abc.html

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!