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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:11:30947browse


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


回复讨论(解决方案)

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

$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);}

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