-3

我想通过 php preg_march 从电子邮件中获取文本,我的文本如下所示:

Details: Cras ultrices quam id nisl

Additional Informations
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc eu enim non ipsum feugiat aliquam. Cras eget orci tellus, ac feugiat ligula.
Proin tristique lobortis lacinia. Morbi facilisis

Next line with value: Lorem ipsum dolor sit

我想在“附加信息”下方获取所有信息,直到空行。

4

1 回答 1

0
'~Additional Informations\\r?\\n(.+?)\\r?\\n\\r?\\n~si'

试试这个。

它确实有效:

$string = <<<SZ
Details: Cras ultrices quam id nisl

Additional Informations
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc eu enim non ipsum feugiat aliquam. Cras eget orci tellus, ac feugiat ligula.
Proin tristique lobortis lacinia. Morbi facilisis

Next line with value: Lorem ipsum dolor sit
SZ;
preg_match('~Additional Informations\\r?\\n(.+?)\\r?\\n\\r?\\n~si', $string, $matches);
var_dump($matches[1]);
于 2012-10-27T13:10:00.487 回答