Maison > Article > développement back-end > 求正则表达式解决方法
求正则表达式
字符串:
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <a href="teamMemberDisplay.php?tid=650" title="Team">SW Design and ISS Scrum Team 2</a><br> <a href="programDisplay.php?pid=17" title="Program/Domain/BU">LR RF & HW Modules</a>-><a href="tdlDisplay.php?pid=119" title="Technical Domain">LR WCDMA CPRI Baseline</a>-><a href="projectDisplay.php?pid=123" title="Project">LR CPRI Misc.</a>-><a href="teamMemberDisplay.php?tid=576" title="Team">SW Dev and Test</a>
$str=SW Design and ISS Scrum Team 2<br> <a href="programDisplay.php?pid=17" title="Program/Domain/BU">LR RF & HW Modules</a>-><a href="tdlDisplay.php?pid=119" title="Technical Domain">LR WCDMA CPRI Baseline</a>-><a href="projectDisplay.php?pid=123" title="Project">LR CPRI Misc.</a>-><a href="teamMemberDisplay.php?tid=576" title="Team">SW Dev and Test</a> html; //echo $str;quit(); preg_match_all('/(?:\s+|->)<a>]*>(.*)/isU',$str,$arr); print_r($arr[1]); <br><font color="#e78608">------解决方案--------------------</font><br>$text=array();<br>$html="</a><a href="%5C%22teamMemberDisplay.php?tid=650%5C%22" title="Team">SW Design and ISS Scrum Team 2</a><br><br><a href="%5C%22programDisplay.php?pid=17%5C%22" title="Program/Domain/BU">LR RF & HW Modules</a><br><a href="%5C%22tdlDisplay.php?pid=119%5C%22" title="Technical Domain">LR WCDMA CPRI Baseline</a><br><a href="%5C%22projectDisplay.php?pid=123%5C%22" title="Project">LR CPRI Misc.</a><br><a href="%5C%22teamMemberDisplay.php?tid=576%5C%22" title="Team">SW Dev and Test</a>";<br>preg_match_all('|Program\/Domain\/BU\'>(.+)|',$html, $matches);<br>$text[0]=$matches[1][0];<br>preg_match_all('|Technical Domain\'>(.+)|',$html, $matches);<br>$text[1]=$matches[1][0];<br>preg_match_all('|Project\'>(.+)|',$html, $matches);<br>$text[2]=$matches[1][0];<br>preg_match_all('|title=\'Team\' >(.+)|',$html, $matches);<br>$text[3]=$matches[1][1];<br>print_r($text); <br><font color="#e78608">------解决方案--------------------</font><br>(?:Expression) 非捕获组 进行子表达式Expression的匹配,并将匹配内容保存到最终的整个表达式的区配结果中,但Expression匹配的内容不单独保存到一个组内 <br><br>| 或的意思 <div class="clear"> </div>