正则表达式会匹配 while/loop 双花括号包含双花括号吗?
<?php
$str = '<html lang="{{var doc-lang}}">
<head>
<title>{{var doc-title}}</div>
</head>
<body>
<div class="container">
<div class="row" {{while products}}>
{{var name}}
{{var sku}}
{{var barcode}}
</div {{while end}}>
</div>
</body>
</html>';
我们能得到
<div class class="row"', [products], {{var name}}, {{ var sku}} and {{var barcode}}
从$str
?
我只能想到这个Reg
\<((.*)\{\{while\s+(.*)\}\}(.*)\{\{while\s+end\}\})\>