Image

Imagenomadphoenix wrote in Imagephp 😟anxious

Regex fun - nested "tags". (x-posted to linux)

I am still learning Regex's so doing crafted complicated patterns is just a little bit out of my reach.

What I am trying to do:
Messing around with different output handling schemes for a webscript. The logic I am using is that at the end output would be broken down into blocks. So inner most tags would all be appended to a buffer of that tagName. So at the end of script execution I might have 2+ buffers of names like system,application,template, etc that I can then handle. One of the justifications for investing time in this is to come up with some sort of sectionized caching system (so everything is rendered previously except say 1 small section). Otherwise if regex can't do this fast enough, another thought was to "improve" the PHP output buffering system.


What I got: '(?:%OB_(?P[A-Z]*)%\n?(?P.*)\n?%/OB_\1%)'
Mode: Single-Line
Engine: PHP/PRCE

Test data:
%OB_SYS%
System started: 0492
Good to go!
%OB_APP%
<html>
    <head>
 <title>This is a test</title>
    </head>
    <body>
 %OB_TEMP%
 Hello world!
 This
 is
 a
 test
 %/OB_TEMP%
    </body>
</html>
%/OB_APP%
System closing up
%/OB_SYS%