关于字符串的操作,可能需要用到正则,觉得很复杂解决思路

WBOY
Release: 2016-06-13 13:52:38
Original
775 people have browsed it

关于字符串的操作,可能需要用到正则,觉得很复杂
一个字符串,形式如下:


...

...

...
(也就是,字符串可以看成,由多个以
开头并以
结尾的子串组成)。


现在想:

传入一个索引值(比如i),从0开始,把这样的字符串中的第i+1个子串删除,比如,i=1,就删除原字符串中的第2个以
开头并以
结尾的子串。


请问,如何实现呢?

------解决方案--------------------
pcre_match_all( "/
(?:.|\n|\r)*
/iU ",$str,$array);
echo "

  "; <br> print_r($array); <br>  <br> 剩下的你应该会做了
<br><font color="#e78608">------解决方案--------------------</font><br>$str=preg_replace( '/(( <br> .*   <br> ){ '.$i. '}) <br> .*   <br> /isU ', '\1 ',$str);
<br><font color="#e78608">------解决方案--------------------</font><br>一直有点小东西不太明白 <br> isU  是什么东西??? <div class="clear">
                 
              
              
        
            </div>
Copy after login
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!