求一个正责表达式,我写的不知道为啥不行 打印$d 里包含]*>([sS]*)之间的类容

php中文网
发布: 2016-06-23 13:10:58
原创
1178人浏览过

        $a = '<dl class="info_l">                    <dd class="__r_c_" pan="m14_movie_overview_baseinfo"><strong>导演:</strong>                        <a href="http://people.mtime.com/1654943/" target="_blank" rel="v:directedby">杨庆</a>                    </dd>                    <dd  class="__r_c_" pan="m14_movie_overview_baseinfo"><strong>编剧:</strong>                        <a href="http://people.mtime.com/1654943/" target="_blank">杨庆</a>                    </dd>                    <dd  class="__r_c_" pan="m14_movie_overview_baseinfo">                        <strong>国家地区:</strong>                            <a href="http://movie.mtime.com/movie/search/section/?nation=china" target="_blank">中国</a>                    </dd>                  <dd  class="__r_c_" pan="m14_movie_overview_baseinfo">                    <strong>发行公司:</strong>                    <a href="http://movie.mtime.com/company/121271/" target="_blank">五洲电影发行有限公司</a>                    <a href="http://movie.mtime.com/229813/details.html#company" target="_blank">...</a>                  </dd>                    <dt class="__r_c_" pan="m14_movie_overview_plotssummary">                        <h4 class="px14 mt12">                            剧情:</h4>                        <p class="mt6 lh18">在布满防空洞的重庆,三个从初中就“厮混”在一起的好兄弟合伙开着一家火锅店,名为“老同学洞子火锅”。由于经营不善,几人落得只能转让店铺还债。为了店铺能“卖个好价钱”,三人打起了“扩充门面”的主意,自行往洞里开挖。没想到,..</p>                            <p class="tr mt9"><a href="http://movie.mtime.com/229813/plots.html">更多剧情 <i class="gt"></i></a></p>                    </dt>            </dl>';        preg_match_all("<dd[^>]*>([\s\S]*)<\/dd>/isU",$a,$d);        print_r($d);
登录后复制

Flawless AI
Flawless AI

好莱坞2.0,电影制作领域的生成式AI工具

Flawless AI 32
查看详情 Flawless AI


回复讨论(解决方案)

preg_match_all("/<dd[^>]*>([\s\S]*?)<\/dd>/is",$a,$d);
登录后复制

正则没问题,只是少了起始分割符
preg_match_all(" /

]*>([\s\S]*)/isU",$a,$d);

$a = '<dl class="info_l">                    <dd class="__r_c_" pan="M14_Movie_Overview_BaseInfo"><strong>导演:</strong>                        <a href="http://people.mtime.com/1654943/" target="_blank" rel="v:directedBy">杨庆</a>                    </dd>                    <dd  class="__r_c_" pan="M14_Movie_Overview_BaseInfo"><strong>编剧:</strong>                        <a href="http://people.mtime.com/1654943/" target="_blank">杨庆</a>                    </dd>                    <dd  class="__r_c_" pan="M14_Movie_Overview_BaseInfo">                        <strong>国家地区:</strong>                            <a href="http://movie.mtime.com/movie/search/section/?nation=China" target="_blank">中国</a>                    </dd>                  <dd  class="__r_c_" pan="M14_Movie_Overview_BaseInfo">                    <strong>发行公司:</strong>                    <a href="http://movie.mtime.com/company/121271/" target="_blank">五洲电影发行有限公司</a>                    <a href="http://movie.mtime.com/229813/details.html#company" target="_blank">...</a>                  </dd>                    <dt class="__r_c_" pan="M14_Movie_Overview_PlotsSummary">                        <h4 class="px14 mt12">                            剧情:</h4>                        <p class="mt6 lh18">在布满防空洞的重庆,三个从初中就“厮混”在一起的好兄弟合伙开着一家火锅店,名为“老同学洞子火锅”。由于经营不善,几人落得只能转让店铺还债。为了店铺能“卖个好价钱”,三人打起了“扩充门面”的主意,自行往洞里开挖。没想到,..</p>                            <p class="tr mt9"><a href="http://movie.mtime.com/229813/plots.html">更多剧情 <i class="gt"></i></a></p>                    </dt>            </dl>';        preg_match_all("/<dd[^>]*>([\s\S]*)<\/dd>/isU",$a,$d);         print_r($d[1]);
登录后复制
Array(    [0] => <strong>导演:</strong>                        <a href="http://people.mtime.com/1654943/" target="_blank" rel="v:directedBy">杨庆</a>                        [1] => <strong>编剧:</strong>                        <a href="http://people.mtime.com/1654943/" target="_blank">杨庆</a>                        [2] =>                         <strong>国家地区:</strong>                            <a href="http://movie.mtime.com/movie/search/section/?nation=China" target="_blank">中国</a>                        [3] =>                     <strong>发行公司:</strong>                    <a href="http://movie.mtime.com/company/121271/" target="_blank">五洲电影发行有限公司</a>                    <a href="http://movie.mtime.com/229813/details.html#company" target="_blank">...</a>                  )
登录后复制
preg_match_all("/

]*>([\s\S]*)/isU",$a,$d);
全能打印神器
全能打印神器

全能打印神器是一款非常好用的打印软件,可以在电脑、手机、平板电脑等设备上使用。支持无线打印和云打印,操作非常简单,使用起来也非常方便,有需要的小伙伴快来保存下载体验吧!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号