Post Reply 
$NEST|$INEST : less than L loops
Dec. 18, 2009, 07:50 PM
Post: #1
$NEST|$INEST : less than L loops
Code:
[Patterns]
Name = "$NEST less than L loops"
Active = FALSE
Limit = 25600
Match = "<(table)\1"
        "$SET(L=iii)"
        "&"
        "$NEST(<$TST(\1)"
        "($SET(c=$GET(c)i)(^$TST(c=$TST(L)))"
        "|$SET(L=)$SET(c=))$TST(L=ii+),</$TST(\1) >)"
        "$TST(L=ii+)"
        "$SET(L=)$SET(c=)"

Test against:

Code:
<table>III
<table>II
<table>I
</table>
</table>
</table>

Result:

Code:
<table>III

</table>

Change iii in $SET(L=iii) to vary maximum number of loops allowed,
ii is less than two,
iii is less than three,
etc.

Basic idea should also work with $INEST.
More tests can be added.

I haven't done much with it.
Report oddities.

Have fun
Add Thank You Quote this message in a reply
Dec. 18, 2009, 08:34 PM
Post: #2
RE: $NEST|$INEST : less than L loops
Nice lesson JJoe! With your permission i will add it to the base config in the section Code examples with the title "<example> $NEST less than L loops {JJoe}091218"
Add Thank You Quote this message in a reply
Dec. 18, 2009, 11:40 PM
Post: #3
RE: $NEST|$INEST : less than L loops
(Dec. 18, 2009 08:34 PM)lnminente Wrote:  With your permission

Just make sure it works. Wink

My hope was to save some time and buffer space,
$NEST(<table,</table >) can use a lot of both before it fails.
Testing seemed to show success.

The posted example counts 'loops'.
<table><table></table><table></table></table>
is three loops.

It is also possible to count 'layers'.
<table><table></table><table></table></table>
would be two layers, iirc.

Have fun
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: