On Wed, 20 Sep 2000 18:28:55 +0800, Thomas Fernandez wrote:

TF> Hi Krister,

TF> On Wed, 20 Sep 2000 11:32:22 +0200GMT (20/09/2000, 17:32 +0800GMT),
TF> Krister Ekstrom wrote:

KE>> I have noticed that some people on this list in their reply
KE>> templates write something like "on date time, which is date time
KE>> where i live you wrote:" how do you accomplish this, ie what
KE>> macros do you use to get the time difference? Thanks!

TF> 
On%SETPATTREGEXP="(?m-s)Date\:\s*?((.*?[\d]{4})\s*?([\d]{0,2}\:[\d]{0,2})\s*?(.*))"%REGEXPMATCH="%HEADERS"GMT
 (%ODateShort, %OTime in Taiwan),

TF> Don't ask me to explain it to you... I don't udnerstand it myself!
TF> Somebody posted in on the list.

When this RegExp first came up, Alexander Kiselev posted the following
explanation:
================
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:-))
================

Regards

Peter
-- 
Peter Steiner <[EMAIL PROTECTED]>

-- 
--------------------------------------------------------------
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]>
--------------------------------------------------------------

You are subscribed as : [email protected]


Reply via email to