Home > Backend Development > PHP Tutorial > 匹配页面上某个class的正则怎么写

匹配页面上某个class的正则怎么写

WBOY
Release: 2016-06-23 13:11:30
Original
932 people have browsed it


想要匹配上图中class="rest"和class="count" 这个正则要怎么写


回复讨论(解决方案)

preg_match_all('/class="(rest|count)">(\d+)</',$s,$m);
Copy after login

$result = preg_match('/class="rest">([0-9]+)/', $html, $rest);if ($result) {	var_dump($rest);}$result = preg_match('/class="count">([0-9]+)/', $html, $count);if ($result) {	var_dump($count);}
Copy after login

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