Home  >  Article  >  Backend Development  >  考验你的正则知识,该怎么处理

考验你的正则知识,该怎么处理

WBOY
WBOYOriginal
2016-06-13 10:14:33950browse

考验你的正则知识
192.168.93.24`2012-03-31 10:02:05`GET /91063b13bf8ba59b896804d829b0ff20/0/0/apk/index.php?system=source&module=bibei&app=0&f=9_3_0_0_0`http://192.168.93.55:9090/apk/index.php?app=0`Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.0 Safari/535.7

有这么一个字符串,注意里面有这么一个串f=9_3_0_0_0,它可能有,也可能没有,它的位置不固定,只知道肯定在问好后面,`前面,现在要做这么一个事情,试图匹配到f=后面的5个数字(不是固定的), 如果没有f参数,获取全部为空就可以了,请大神出招。谢谢!

------解决方案--------------------
这样?
preg_match_all('/\bf=([\d_]+)\b/m', $s, $r);
print_r($r[1]);

Array
(
[0] => 9_3_0_0_0
)

------解决方案--------------------
楼主这题目看了半天

PHP code
$str=<font color="#e78608">------解决方案--------------------</font><br>
探讨

把帖子更新一下:
192.168.93.24`2012-03-31 10:02:05`GET /91063b13bf8ba59b896804d829b0ff20/0/0/apk/index.php?system=albums&module=list&app=0`http://192.168.93.55:9090/apk/index.php?syste
m=source&……
Statement:
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