procmail
[Top] [All Lists]

Re: MATCH bug?

1998-06-23 01:24:06
|Mon 1998-06-22 Stan Ryckman <stanr(_at_)sunspot(_dot_)tiac(_dot_)net> 
list.procmail
| Procmail 3.11pre7.  Maybe there's something wrong with my
| brain, but I can't see how CASE2 could become anything but either
| "18:" or "51:" in the following, which I stumbled on while
| playing with breaking up a From_ line:

[   
    If you're interested, I just wrote new module to support your
    From_ line syntax. It's called pm-jadate5.rc (See X-info File
    Server) and it parses

        Fri Jun 19 18:51:56 1998 11:43:23 
    
    To variables 

        YYYY    = 4 digits
        YY      = 2 digits
        MON     = 3 characters
        MM      = 2 digits
        DAY     = 3 characters
        DD      = 2 digits
        hh      = 2 digits      If available
        mm      = 2 digits      If available
        ss      = 2 digits      If available
 
]

You used recipe:

     FROMLINE = "From someone(_at_)somewhere(_dot_)com  Fri Jun 19 18:51:56 
1998"

     :0
     * FROMLINE ?? .*\/..:
     {
        CASE1 = $MATCH              # Assigning "CASE1=18:"
     }

     :0
     * FROMLINE ?? [^ ]+ +.*\/..:   # Assigning "CASE2= Fri Jun 19 18:51:"
     {
        CASE2 = $MATCH
     }

| Huh?
| 
| BTW, without the "+" just before the ".*" the result is "18:";
| however, " +.*" should be the same as " .*", right?

I'm sure Phil or David can give "under the hood" explanation, but
my understanding is that this is the stingy vs. greedy race condition
in the context of \/ operation.

    From someone(_at_)somewhere(_dot_)com  Fri Jun 19 18:51:56 1998
                               ==================

    [^ ]+ +.*\/..:

Tha part to the left matches as little as possible (stingy) and right 
hand matches as much as possible. I assume procmail interpretes the
regexp as

        [^ ]+ +     # find place where there is two spaces

And because next regexp does not NEED TO match anything

        .*          

procmail stops there and switches to greedy mode and matches anything to the
Next significant marker ":"

        ..:         # The preceeding "." regexps match anything

And now we have match

        From someone(_at_)somewhere(_dot_)com  Fri Jun 19 18:51:56 1998

        Assigning "CASE2= Fri Jun 19 18:51:"

jari

    


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