procmail
[Top] [All Lists]

Re: Getting partial matches from a string without forking an outside process

2005-01-09 13:25:35
On Sun, 09 Jan 2005, 19:39 GMT+01 Dallman Ross wrote:

On Sun, Jan 09, 2005 at 02:44:10PM +0100, Robert Allerstorfer wrote:

Your recipe does only result in the left part, but not in the right
one.

Okay, but as Ruud showed, once we have our foreshortened string, it's
trivial to then find the right side.

  :0
  * fullstring ?? ^^$\leftpart\/.*
  { rightpart = "$MATCH" }

yes, I am using such constructs several times in other parts of my
SoftlabsAV package (however it's not needed in my 'av_split.inc'
routine). If I would use that recipe here, I would add the 'D' flag,
to increase performance (no need to allow case-insensitivity here).

If you have a look into 'av_split.inc', you will see that my solution
is done using simple code:

 MATCH
 :0
  * av_SPLIT_STRING ?? ^^\/.
  {
     av_SPLIT_LEFT = "$av_SPLIT_LEFT$MATCH"
  }

 MATCH
 :0
  * av_SPLIT_STRING ?? ^^.\/.*
  {
     av_SPLIT_STRING = $MATCH
  }

 :0
  * $ $av_N ^0
  *      -1 ^0
  {
     av_N = $=
     INCLUDERC = $_
  }

 :0 E
  {
     av_SPLIT_RIGHT = $av_SPLIT_STRING
     av_SPLIT_STRING
  }

# We currently always break the string from left to right. If the right part
# is shorter than the left one, parsing from the other direction would be
# faster. For the time being, however, I don't care. 

Neither do I.

Btw, I think the "E" flag there at the end is unnecessary, though harmless
enough.

The 'E' flag may not be needed, but makes the code clearer to read and
understand, at least for me.

rob.


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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