fork download
  1. <?php
  2.  
  3. $content = <<<HTML
  4. <p>{wrapper btnlabel=&quot;AAA&quot;}zzzzzzzzzzzzzzzzzzzz{/wrapper}</p>
  5.  
  6. <p>{wrapper btnlabel=&quot;Text&quot;}</p>
  7.  
  8. <table>
  9. <tbody>
  10. <tr>
  11. <th scope="row">123</th>
  12. <td>1 123</td>
  13. <td>12 123</td>
  14. <td>3 123</td>
  15. <td>1 123 123</td>
  16. </tr>
  17. <tr>
  18. <th scope="row">123</th>
  19. <td>2700 123.</td>
  20. <td>1800 123.</td>
  21. <td>1000 123.</td>
  22. <td>300 123.</td>
  23. </tr>
  24. </tbody>
  25. </table>
  26.  
  27. <p>{/wrapper}</p>
  28. HTML;
  29.  
  30. preg_match_all('#(?>{wrapper btnlabel=(?>"|&quot;)(.+?)(?>"|&quot;)})(.*?){/wrapper}#s', $content, $matches);
  31. var_dump($matches);
Success #stdin #stdout 0.02s 24144KB
stdin
Standard input is empty
stdout
array(3) {
  [0]=>
  array(2) {
    [0]=>
    string(64) "{wrapper btnlabel=&quot;AAA&quot;}zzzzzzzzzzzzzzzzzzzz{/wrapper}"
    [1]=>
    string(301) "{wrapper btnlabel=&quot;Text&quot;}</p>

<table>
<tbody>
<tr>
<th scope="row">123</th>
<td>1 123</td>
<td>12 123</td>
<td>3 123</td>
<td>1 123 123</td>
</tr>
<tr>
<th scope="row">123</th>
<td>2700 123.</td>
<td>1800 123.</td>
<td>1000 123.</td>
<td>300 123.</td>
</tr>
</tbody>
</table>

<p>{/wrapper}"
  }
  [1]=>
  array(2) {
    [0]=>
    string(3) "AAA"
    [1]=>
    string(4) "Text"
  }
  [2]=>
  array(2) {
    [0]=>
    string(20) "zzzzzzzzzzzzzzzzzzzz"
    [1]=>
    string(256) "</p>

<table>
<tbody>
<tr>
<th scope="row">123</th>
<td>1 123</td>
<td>12 123</td>
<td>3 123</td>
<td>1 123 123</td>
</tr>
<tr>
<th scope="row">123</th>
<td>2700 123.</td>
<td>1800 123.</td>
<td>1000 123.</td>
<td>300 123.</td>
</tr>
</tbody>
</table>

<p>"
  }
}