求正则表达式解决方法

php中文网
发布: 2016-06-13 13:46:13
原创
1870人浏览过

求正则表达式
字符串:

PHP code
<!--

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>

登录后复制


求将 LR RF & HW Modules,LR WCDMA CPRI Baseline, LR CPRI Misc. ,SW Dev and Test 这四个取出来的正则,以及只取出LR RF & HW Modules的正则表达式。
我在php里用的函数是preg_match.
谢谢了!!

------解决方案--------------------
PHP code

$str=SW Design and ISS Scrum Team 2<br><a href="programDisplay.php?pid=17" title="Program/Domain/BU">LR RF &amp; 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>]*&gt;(.*)/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 &amp; 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\'&gt;(.+)|',$html, $matches);<br>$text[0]=$matches[1][0];<br>preg_match_all('|Technical Domain\'&gt;(.+)|',$html, $matches);<br>$text[1]=$matches[1][0];<br>preg_match_all('|Project\'&gt;(.+)|',$html, $matches);<br>$text[2]=$matches[1][0];<br>preg_match_all('|title=\'Team\' &gt;(.+)|',$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>
登录后复制
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源: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号