0

我想提取这一行

<p>@include{"portal.shared.blook"}</p>

使用

preg_grep("/(\s*@include.*)/",explode("\n", $Source)) 

从这个源代码

<html>
   <head>
        <title>hi</title>
   </head>
   <body>
        <h1>Hi I am layout</h1>
        <br>
        <p>@include{"portal.shared.blook"}</p>
        @require{"portal.shared.footer":"[main]"}

有时代码有空格,我无法处理

4

1 回答 1

1

尝试这个:

(?<=\<\w\>)(\s*@include.*)(?=\<\/\w\>)

工作示例: https ://regex101.com/r/wM1lB8/2

于 2015-11-11T07:10:22.687 回答