Replace all data within the tag with regular expressions

WBOY
Release: 2016-07-29 08:51:16
Original
1021 people have browsed it
<pre class="brush:php;toolbar:false"><span>$str </span><span>= </span><span>'<div class="graw">-----------标签内容-----------</div>'</span><span>;</span>
Copy after login
<span>$content = '</span><ul class="ke-list fix list-paddingleft-2">
            <li>
                <div class="ke-img">
                    <a href="http://www.kgc.cn/uiue" target="_blank" title="移动端UI设计">                            <img src="/upload/ad/1449212378483757.jpg" alt="移动端UI设计"/></a>
                </div>
                <div class="ke-txt">
                    <h3>
                        移动端UI设计
                    </h3>
                    <p>
                        联合多位UI设计师、UE交互设计师、产品经理大牛倾力打造,通过多个企业真实项目实践及线下翻转课堂,全面讲解和训练目前热门的移动端主流应用App设计、用户体验(UE)与交互设计、Axure产品原型设计、跨平台(iOS/Android )、多终端设计(手机/Pad/智能电视/微信新媒体),带你快速成长为移动互联网时代最抢手的移动端UI设计师、UE交互设计师。
                    </p>
                </div>
            </li>
            <li>
                <div class="ke-img">
                    <a href="http://www.kgc.cn/media" target="_blank" title="新媒体体系课程">                            <img src="/upload/ad/1449213144964572.jpg" alt="新媒体体系课程"/></a>
                </div>
                <div class="ke-txt">
                    <h3>
                        <pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false">                                            [<span>replyview</span>]新媒体体系课程[/<span>replyview</span>]
Copy after login

                                                                                                                                                                                                                                             Here, you will learn, interact, and complete homework exercises under the leadership of live teachers until you master the real skills to be qualified for corporate work. Here, you will find all the useful information related to new media in one place: software, books, information integration posts...all are provided for you, saving you time in searching the entire Internet. Here, you can get to know new media colleagues across the country, communicate with them, learn from them, and become friends. Here, start your new media learning journey now! /& Lt;/p & gt;
& lt;/div & gt;
& lt;/li & gt;
& lt; li & gt;
& lt; p & gt; t; & & lt;/ li>
               ';


preg_match_all("|

[
replyview](.*)
[/
replyview]|U" , $content , $match);foreach($match[1] as $key=> $val){ $pattern[$key] = "/[replyview(.+?)/replyview]/";$replacement [ $key] = $str.$match[1][$key];}$text = preg_replace ($pattern,$replacement,$content , 1); The above introduces the use of regular expressions to replace all data in tags, including aspects. I hope it will be helpful to friends who are interested in PHP tutorials.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
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!