Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 解析HTML块的特定部分_Php_Regex_Parsing - Fatal编程技术网

Php 解析HTML块的特定部分

Php 解析HTML块的特定部分,php,regex,parsing,Php,Regex,Parsing,我正在从一个类似这样的网站中提取一个HTML块 <strong>Suggested use:</strong> "This is the suggested use text" <br><br> <strong>Warning:</strong> "This is the warning text" 建议使用: “这是建议使用的文本” 警告: “这是警告文本” 我试图只提取建议使用块下的文本和警告块下的文本的值,并

我正在从一个类似这样的网站中提取一个HTML块

<strong>Suggested use:</strong> 
"This is the suggested use text"
<br><br>
<strong>Warning:</strong> 
"This is the warning text"
建议使用:
“这是建议使用的文本”


警告: “这是警告文本”

我试图只提取建议使用块下的文本和警告块下的文本的值,并将它们存储在两个单独的字段中。我很难弄清楚如何具体解析这个。有人有什么想法吗?

我看到你把这个标记为regex,所以:

$str  = '<strong>Suggested use:</strong> "This is the suggested us text" <br><br> <strong>Warning:</strong> "This is the warning text"';

if (preg_match_all('/"([^"]+)"/', $str, $m)) 
    print_r($m[0]);  
$str='建议使用:“这是建议的美国文本”

警告:“这是警告文本”; if(preg_match_all(“/”([^“]+)“/”,$str,$m)) 印刷费($m[0]);
输出:
数组([0]=>“这是建议使用的文本”[1]=>“这是警告文本”)

如果您不想引用,也可以使用:print_r($m[1])


编辑:我以为我在PHP部分,所以假设它是PHP正则表达式,进行一些澄清会很好。

到目前为止您尝试过什么吗?它是什么语言或工具?您可以添加html文档的较大部分吗?我想查看文档这部分的父节点