Hi there!
On 13 Dec 99, at 23:57, Ali Martin wrote
about "Re: Solution to %DATE and %TIME mac":
> AM>> As you can see in my greeting, it works nicely. Check the RFC
> AM>> Headers for your message and see. :)
>
> > Wow, it works! even I don't know how it work :-).
>
> Alexander thinks it's a piece of cake. :)))
Yes, and for those who really care about *how* it works, read
the following, please (hmmm, probably not technically-minded
people have no need in reading it anyhow... and probably I
should have posted it to TBBETA instead... but well, I'm too
tired to think right now.... good night to all of you!):
Well, here's what my own regexp that's working for me does:
(?m-
s)Date\:\s*?((.*?[\d]{4})\s*?([\d]{0,2}\:[\d]{0,2}\:[\d]{0,2})\s*?(.*\
n))
1. (?m-s) is a sequence of "switches". ?m is turning "multiline
mode" ON (the %HEADERS data is treated as a sequence of
lines terminated with newline characters (\n)), otherwise it
would consider the data as one long string; (?-s) instructs TB
*not* to match newlines when "." wildcard is used (which, in
turn, stands for "any character"). In our case we want "." to
stand for "any character but newline", since the Date: field
always occupies a single line --- it's a foolproof switch here...
2. Date\: means "Date:". We want to match the data that follows
the Date: string in %HEADERS.
3. \s*? stands for "any number of spaces" after the "Date:"
string, ungreedily (see help file)
4. (.....) --- start capturing the data that we're going to insert
into TB message.
5. (.*?[\d]{4}) --- captured substring. We want to capture not a
single string, but to capture a set of strings via
%PATT="number". This is done exactly this way: TB counts the
opening brackets, and numbers internally the strings found in
each pair of them. So the match from this very pair of brackets
will be number 2... Inside the brackets we have: .*? -- stands
for any number of any characters ungreedily, [\d]{4} -- stands
for the sequence of exactly four of any decimal digits. All in all
in our case it matches the "Sun, 12 Dec 1999" string.
6. \s*? --- again any number of spaces, ungreedily.
7. ([\d]{0,2}\:[\d]{0,2}\:[\d]{0,2}) --- capturing (since in
brackets) subpattern, which matches "0 to 2 decimal digits,
followed by a ":" symbol, followed by 0 to 2 decimal digits,
followed by another ":" symbol, followed again by 0 to 2
decimal digits". This one in the case of your own message
matched "23:10:32", of course:-)
8. \s*? again any number of spaces ungreedily.
9. (.*\n) --- capturing subpattern, which matches "any number
of any characters, but NOT newlines (therefore this is all the
rest of the string started with Date:) and the newline at the end
of it." In the case of your message, it matched "+0300\n" (here
\n is treated exactly as in cookies: forced newline). After you
modified my initial regexp, it became "+0300", because now
the newline itself is not matched (since .* matches everything
up to the end of the line, but NOT newline itself, see the -s
switch).
I believe, it's quite simple indeed:-))
>
> --
> Ali Martin | Using The Bat! v1.38e
> mailto:[EMAIL PROTECTED] | Windows NT 4.0 (Service Pack 6)
>
> [ Oxymoron: Too Many Taglines. ]
> ___
>
> --
> --------------------------------------------------------------
> View the TBUDL archive at http://tbudl.thebat.dutaint.com
> To send a message to the list moderation team double click here:
> <mailto:[EMAIL PROTECTED]>
> To Unsubscribe from TBUDL, double click here and send the message:
> <mailto:[EMAIL PROTECTED]>
> --------------------------------------------------------------
>
>
>
--
SY, Alex
(St.Petersburg, Russia)
http://mph.phys.spbu.ru/~akiselev
---
Thought for the day:
Your reality check just bounced.
---
PGP public keys on keyservers:
0xA2194BF9 (RSA); 0x214135A2 (DH/DSS)
fingerprints:
F222 4AEF EC9F 5FA6 7515 910A 2429 9CB1 (RSA)
A677 81C9 48CF 16D1 B589 9D33 E7D5 675F 2141 35A2 (DH/DSS)
---
--
--------------------------------------------------------------
View the TBUDL archive at http://tbudl.thebat.dutaint.com
To send a message to the list moderation team double click here:
<mailto:[EMAIL PROTECTED]>
To Unsubscribe from TBUDL, double click here and send the message:
<mailto:[EMAIL PROTECTED]>
--------------------------------------------------------------