On Sat, Jul 24, 2004 at 01:27:12PM -0600, Justin Gombos wrote:
With dman's help, I've written the following code to extract the year
from a message. Here's what I have so far:
ARCHIVING=true
# Extract the year from the date that the author
# *claims* to have composed the message.
#
# Note: this recipe will result in a null value
# for dates formed as XX-XX-XX.
#
:0
* ^Date:.*\/(19|20)?[0-9][0-9][^a-z]+:
* MATCH ?? ^^\/[^ ]+
* 19^0 MATCH ?? ^^19..^^
* 20^0 MATCH ?? ^^20..^^
* 19^0 MATCH ?? ^^[^0].^^
* 20^0 MATCH ?? ^^0.^^
* MATCH ?? ^^.*(19|20)?\/[0-9][0-9]^^
{ STATED_YEAR = $=$MATCH }
# Alternative approach to extracting year from Date: field
#
#STATED_YEAR=`formail -x "Date: " | sed -e 's/.*
\([12]\{,1\}[90]\{,1\}[0-9][0-9]\) .*/\1/' \
# -e 's/^[^0][0-9]$/19&/g' \
# -e 's/^[0][0-9]$/20&/g'`
Why not use GNU date, ie.
date -d "`formail -x Date:`" +%Y
--
William Park, Open Geometry Consulting, <opengeometry(_at_)yahoo(_dot_)ca>
Toronto, Ontario, Canada
____________________________________________________________
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