Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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_Filter - Fatal编程技术网

如何在php中使用正则表达式过滤html邮件作为回复

如何在php中使用正则表达式过滤html邮件作为回复,php,regex,filter,Php,Regex,Filter,我收到这样的html邮件 <div dir="ltr">last message</div> <div class="gmail_extra"> <br> <div class="gmail_quote"> 2016-04-09 16:30 GMT+04:00 <span dir="ltr">&lt;<a href="mailto:mymail@example.c

我收到这样的html邮件

<div dir="ltr">last message</div>
<div class="gmail_extra">
    <br>
    <div class="gmail_quote">
        2016-04-09 16:30 GMT+04:00
        <span dir="ltr">&lt;<a href="mailto:mymail@example.com" target="_blank">mymail@example.com</a>&gt;</span>:
        <br>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div class="HOEnZb">
                <div class="h5">
                    On 2016-04-09 13:05, repliername repliersurname wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                        the third reply message text<br>
                        On Fri, Apr 8, 2016 at 10:47 PM, &lt;<a href="mailto:mymail@example.com" target="_blank">mymail@example.com</a>&gt; wrote:<br>
                        <br>
                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                            On 2016-04-08 21:14, repliername repliersurname wrote:<br>
                            <br>
                            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                the first reply message text<br>
                            </blockquote>
                            <br>
                            the second reply message text<br>
                        </blockquote>
                    </blockquote>
                    <br>
                </div>
            </div>
            the fourth reply message text<br>
        </blockquote>
    </div>
    <br>
</div>
$mail = [
            "content" => "last message",
            "replies" => [
                "date" => "2016-04-09 16:30",
                "from" => "mymail@example.com",
                "content" => "the fourth reply message text",                
                "reply" => [
                    "date" => "016-04-09 13:05",
                    "from" => "repliername repliersurname",
                    "content" => " the third reply message text",
                    "reply" => [
                        "date" => "2016-04-08 22:47",
                        "from" => "mymail@example.com",
                        "content" => "the second reply message text",
                        "reply" => [
                            "date" => "2016-04-08 21:14",
                            "from" => "repliername repliersurname",
                            "content" => "the first reply message text"
                        ]
                    ]
                ]
            ]
        ];
它必须用正则表达式进行过滤。。。 请帮帮我。。。
我不知道该怎么做…

我解决了正则表达式的问题

preg_match('#<blockquote[^>]+>(.+?)</blockquote>#ims', $text, $matches);
        echo "<pre>";
        print_r($matches);