这是我regex101例如其中的工作原理:https://regex101.com/r/fE6rO9/2(你不得不等待几个secondes,因为它的大)的preg_match正则表达式不会找到匹配(但它适用于regex101)
这里是我的PHP
$content = htmlentities($contentCode);
/* correct echo when i copy paste it into regex101 */
echo $content;
// copy past from regex101
$re = "/<\\/form><table class=\"forumline\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">(.*)<\\/table><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">/";
preg_match($re, $content, $matches);
var_dump($matches);
但我运行它时,它回响:
array (size=0)
empty
任何想法是什么问题是?
这是正则表达式采取APPART:
"/<\\/form><table class=\"forumline\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">(.*)<\\/table><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">/";
请发布明确的*** ***输入和期望的输出*** ***示例 –
主要问题是您使用正则表达式来解析html。花时间学习如何使用DOMDocument。 –
所需的输出是在该链接:https://regex101.com/r/fE6rO9/2 =>我期望1输出,1匹配 – Couteau