procmail
[Top] [All Lists]

RE: More Bouncing off of Infinity

2003-01-13 06:09:43
I wrote last night:

P.S.  Another good use for "IB" will be to save a preset, manageable
number of chars to a MATCH variable for later manipulation and
testing.  We couldn't do that before without resorting to shell
tools to help with the parsing; and that was costly.  An example
of this use would be in searches for viruses, whose characteristic
signatures are typically found near the front of message bodies.

Well, I spoke too quickly, I think, to say there were no other good ways
to save a set number of chars.  I should have listened to the voice in
my head that told me, as I wrote "couldn't do that before," that this
is seldom true when it comes to computers.  When I read or want to
write "only way," "best way," "impossible," I usually balk, because
it's usually not true.

Here's a thought for saving, say, 256 chars.  Make sure your LINEBUF
is reasonable, btw.

ONE        = (^.|.$|^$|.)
TWO        = ${ONE}${ONE}
SIXTEEN    = ${TWO}${TWO}${TWO}${TWO}${TWO}${TWO}${TWO}${TWO}
SIXTYFOUR  = ${SIXTEEN}${SIXTEEN}${SIXTEEN}${SIXTEEN}
TWOFIVESIX = ${SIXTYFOUR}${SIXTYFOUR}${SIXTYFOUR}${SIXTYFOUR}

:0
* B ?? ^^\/$TWOFIVESIX
{ BODYTOP = $MATCH }

I've only tested this briefly, but it seems to work.

The "IB" (infinity-bouncing) method for the same, I frankly admit
I can't quite work out yet.  However, here's something equally cool:  
We can now extract the nth instance of anything we want from a 
message!

Here's a sample that saves the third URL in a message, or,
if there aren't three or more, exits quietly:

SUPREMUM = 2147483647
WS       = "    "    # that was a space and a tab inside the quotes

:0
*            -3^0
* $   $SUPREMUM^0
* $           1^1   B ?? ()\/http://[^$WS]+
* $  -$SUPREMUM^0
{ THIRDURL = $MATCH }

Woo-hoo!!

-- 
        "Weltbedenkend, ortlich lenkend!"
                -- Original von Dallman Ross


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>