如何使用php脚本的正则表达式提取itemid=后面变量3这个值?我现在用的是PHP code preg_match_all('/buy"/> 如何使用php脚本的正则表达式提取itemid=后面变量3这个值?我现在用的是PHP code preg_match_all('/buy">

Home  >  Article  >  Backend Development  >  大侠进!正则表达式小语句~

大侠进!正则表达式小语句~

WBOY
WBOYOriginal
2016-06-13 13:08:38793browse

大侠进!求一个正则表达式小语句~~~
各位大侠~
求教一个正则表达式的提取方法:
下面这个地址

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->http://www.daikuan.com/sell/show.php?itemid=3">

如何使用php脚本的正则表达式提取itemid=后面变量3这个值?
我现在用的是
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->preg_match_all('/buy\/show\.php\?itemid=([\'"]?)(\d+)\1(?-i)/', $arrContent[0], $itemidx);

但是这个值没有提取出来。。。
这么办?

------解决方案--------------------
/http:\/\/.*?\?itemid=(\d*)/
没见到括号分组么
------解决方案--------------------
print_r($itemidx);//就知道了

echo $itemidx[1][0] ; //就是了
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