procmail
[Top] [All Lists]

Re: $MATCH expiration day/time

1997-07-04 06:52:00
On Fri, 4 Jul 1997 08:37:11 -0400 (EDT), Bobby <thsk(_at_)netcom(_dot_)com>
wrote:
(Greetings|HaPPy Independence Day|TGIF)

.obI18n: As you can probably guess, to some of us "Independence Day"
is merely the title of a rotten movie. ;^]

I am looking to $MATCH the expiration day/time from a code group
sent with forecast data by the U.S. National Weather Service. 
The general form of the UGC line is as follows:
SSFnnn-(nnn-nnn>nnn-...SSFnnn-SSFnnn-...)DDHHMM-
<...>
It is the DDHHMM that I'm looking to $MATCH.  Here are some
examples:
MAZ501-504-161415-
MAZ002>004-NHZ011-012-022100-
         ^ (a typo, I assume)
MAC027-017-122315-
<...>
My QUESTION is...  How to $MATCH just the DDHHMM without the
leading or trailing dash (-) at the end of the line?

You can do a two-level MATCH to first extract almost the part you
want, and then trim that down to a closer match.

    :0
    * -\/[0-3][0-9][0-2][0-9][0-5][0-9]-$
    * MATCH ?? ^^\/[^-]+
    ...

I plan to use the $MATCH in a 'test' with the current time to see
if the forecast is current before forwarding it to my alphapager.

You can use scoring for the comparison, and save (gasp) one whole
process. Of course, if you are uncomfortable with grabbing the date
from the From_ line, you end up calling date anyway, but this is
probably still less overhead than the solution that you had in mind.
(The DDHHMM strings are of course not really base 10 numbers, but you
can still compare them as long as you can massage them both into the
same format. No point in converting to seconds since the birth of the
universe or anything like that, unless of course you'll end up in
trouble when the month [or the universe :-] rolls over.)

    :0
    * $ -$EXPDATE^0
    * $  $NOWDATE^0
    /dev/null

    :0
    ! forward ...

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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