【发布时间】:2010-10-21 04:42:45
【问题描述】:
是否可以将文件内容拆分为具有特定模式的部分?
这就是我想要实现的目标:
- 使用 file_get_contents 读取文件
- 只读类似评论区域之间的内容。
我不确定这有多复杂,但基本上如果我正在解析一个大的 html 文件并且只想向浏览器显示特定的小部件(模式是注释边界),如下所示:
示例:
<html>
<head>
<title>test</title>
</head>
<body>
this content should not be parsed.. ignored
<!-- widget -->
this is the widget. i want to parse this content only from the file
<!-- widget -->
</body>
</html>
是否可以使用 php 和 regex 或任何东西来解析边界之间的内容?
我很抱歉,但我试图尽可能多地解释我想要实现的目标。希望有人帮助我。
【问题讨论】:
标签: php regex parsing file-get-contents