【问题标题】:How to match html-comment with preg_match_all (PHP)?如何将 html-comment 与 preg_match_all (PHP) 匹配?
【发布时间】:2011-10-18 21:32:39
【问题描述】:

我有这个 HTML 文档:

<!--SETTINGS 
title: This is the title
keywords: dummy, title, longer keyword, another
description: This is the description of the page
 -->

dit is de home dit is de homedit is de homedit is de homedit is de home
dit is de home
dit is de home
dit is de home
dit is de homedit is de homedit is de homedit is de home
dit is de homedit is de homedit is de home

现在,我想匹配开头的评论。我认为我的正则表达式模式如下所示:

<!--SETTINGS([\s\S])*-->

当我在 http://regexr.com?2ucae 中测试它时,一切似乎都正常运行。 当我把它放在 PHP 中时,我得到一个错误:Fout 101 (net::ERR_CONNECTION_RESET): Connection lost.

我做错了什么?

【问题讨论】:

  • XPath //comment() 将匹配 DOMDocument 中的所有 cmets。

标签: php html regex comments


【解决方案1】:

该错误与您的 regex-pattern

无关

检查您的计算机是否存在恶意软件,并对ERR_CONNECTION_RESET进行一些研究

示例:http://www.google.com/support/forum/p/Chrome/thread?tid=476f762a0f84017f&hl=en

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-12
    相关资源
    最近更新 更多