How to extract numbers from a web page?

WBOY
Release: 2016-06-27 13:18:11
Original
1847 people have browsed it

The following string is part of the web page, Season number: More comments (109 in total)
       dfs
Total
109
Article
All 109 items, how to use regular expressions to extract the three numbers 109, $p_search='/(.*)(S*) |(d).*/';What’s wrong with this?


Reply to discussion (solution)

$p_search='/(d )/';
This is enough

(d )

$p_search='/(d ) /';
Isn’t this enough?
You need to extract all 3 109s

$s='<span class="pl">季数:<a href="http://movie.douban.com/subject/3401355/reviews">更多评论(共109条)</a>        dfs<a href="http://movie.douban.com/subject/6973376/reviews">共<span property="v:count">109</span>条</a><a href="http://movie.douban.com/subject/6537486/reviews">全部 109 条</a>';$p_search='#(\d+)(</span>)?\s*条#s';preg_match_all($p_search,$s,$m);print_r($m[1]);
Copy after login

Array
(
[0] = > 109
[1] => 109
[2] => 109
)

PHP code?123456789$s='More reviews (109 in total)   dfsTotal Thank you, I learned a lot of knowledge, and finally I used this $p_review_num='#((?<=More Multiple movie reviews (total)|(?<=reviews">All )|(?<=property="v:count">))(d )()?s*items#s ';Match

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template