Heim  >  Artikel  >  Backend-Entwicklung  >  求正则表达式?解决方案

求正则表达式?解决方案

WBOY
WBOYOriginal
2016-06-13 09:59:10845Durchsuche

求正则表达式???????????????急
$str = '




外语能力



 
   
英语:读写能力精通 | 听说能力熟练


韩语:读写能力一般 | 听说能力良好


德语:读写能力一般 | 听说能力一般


 

我想取出英语 韩语 德语这三个词,用正则表达是怎么写?
用这种格式:
前字符串(?[\s\S]*?)后字符串

------解决方案--------------------
PHP code
$str = '<div id="Div3" class="modResumeInfo">
<div class="title" onclick="clickLabel(rsmEduExCt)">
<div class="dcrL dcrArrowGreen"></div>
<h3>外语能力</h3>
</div>
<div id="Div4" class="content">
<div class="workExCom">英语:读写能力精通 | 听说能力熟练</div>
<div class="workExCom">韩语:读写能力一般 | 听说能力良好</div>
<div class="workExCom">德语:读写能力一般 | 听说能力一般</div>
</div>
</div><!--modResumeInfo结束-->';preg_match_all('@<div class="workExCom">(.+):(.+)</div>@u',$str,$match);var_dump($match[1]);<br><font color="#e78608">------解决方案--------------------</font><br>
PHP code
$str=<div class="title" onclick="clickLabel(rsmEduExCt)">
<div class="dcrL dcrArrowGreen"></div>
<h3>外语能力</h3>
</div><div id="Div4" class="content">       <div class="workExCom">英语:读写能力精通 | 听说能力熟练</div>
<div class="workExCom">韩语:读写能力一般 | 听说能力良好</div>
<div class="workExCom">德语:读写能力一般 | 听说能力一般</div>
</div>   <!--modResumeInfo结束-->TEXT;preg_match_all("/<div>(.*):/",$str,$arr);print_r($arr);<div class="clear">
                 
              
              
        
            </div>
</div>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn