Hello Nick,

ND = Nick Danger 

On  Fri, 12 Jan 2001  at  14:31:37 GMT -0600 (which was 12:31 PM where
I live) witnesses say Nick Danger typed:

ND>   That regex string you created for me yesterday:

ND> 
%SETPATTREGEXP="\d{8}"%REGEXPMATCH="%SETPATTREGEXP=""(\d*)/(\d*)/(\d*)""%REGEXPBLINDMATCH=""%DATESHORT""%SUBPATT=""3""%SUBPATT=""2""%SUBPATT=""1"";;%SUBPATT=""3""0%SUBPATT=""2""%SUBPATT=""1"""

ND> Worked great yesterday, but today it's putting out:  20010121 instead
ND> of: 20010112

ND> I'm guessing something is swapping the date numbers and since
ND> yesterday was 11 it didn't show up.

You're probably right.  I know you've solved the problem externally,
but you will have problems in February for the reason stated by SyP.

The regexp is pretty dumb in terms of what it does, so small typos or
variations will look very odd.  I think the problem is with the string
the inner regexp creates for the outer regexp.

So let me explain what happens, then you can tweak the regexp to suit
your needs exactly.

<part of regexp>
%SETPATTREGEXP=""(\d*)/(\d*)/(\d*)""
</part>

This reads 3 sets of digits separated by '/'.  The sets of digits are
stored in SubPatterns 1, 2 and 3.  So if the date format is
DD/MM/YYYY, then SubPattern 1 holds the month, subpattern 2 has the
day, and 3 has the year.

(Manfred, you can generalize the separator by replacing '/' with '[/]'
and adding whatever separator inside the square brackets.)

<part of regexp>
%SUBPATT=""3""%SUBPATT=""2""%SUBPATT=""1"";;%SUBPATT=""3""0%SUBPATT=""2""%SUBPATT=""1""
</part>

This part of the regexp is combining the sequences of digits.
Remembering that 1 = DD, 2 = MM, 3 = YYYY, then the sequence created
is: YYYYMMDD;;YYYY0MMDD . The extra zero is in case we have a month
with 1 digit.  Now if your Date format is different, then you need to
change the subpattern numbers to reflect the difference.  Also to
handle one digit days, you probably want to change this part to:

<part of regexp>
;;%SUBPATT=""3""%SUBPATT=""2""%SUBPATT=""1"";;%SUBPATT=""3""0%SUBPATT=""2""%SUBPATT=""1"";;%SUBPATT=""3""%SUBPATT=""2""0%SUBPATT=""1"";;%SUBPATT=""3""0%SUBPATT=""2""0%SUBPATT=""1"";;
</part>

Again, I'm assuming the date format DD/MM/YYYY.  Change the subpattern
order to suit your needs.  Now we have a really long string that looks
like: ;;YYYYMMDD;;YYYY0MMDD;;YYYYMM0DD;;YYYY0MM0DD;;

The outer regexp looks at this and looks for the first sequence that
has 8 digits in a row. Note the first part YYYYMMDD;; will have 6 or 7
digits if it is a 1 digit month or day. The second one, YYYY0MMDD is 8
digits only when it is a 1 digit month and a 2 digit day.  I'll let
you work out the rest of the sequence to see when it should be called.

However, as written, the outer regexp will return the wrong result
when it is a two digit month and a 1 digit day.  So the outer regexp
needs to be slightly modified.  Instead of:

%SETPATTREGEXP="\d{8}"

Change this to:

%SETPATTREGEXP=";;(\d{8});;"

Of course now we need to change the type of match we're using, because
we don't want to include the ';;' characters.  So all said and done,
the final regexp should look something like:

<regexp>
%SETPATTREGEXP=";;(\d{8});;"%REGEXPBLINDMATCH="%SETPATTREGEXP=""(\d*)[-/](\d*)[-/](\d*)""%REGEXPBLINDMATCH=""%DATESHORT"";;%SUBPATT=""3""%SUBPATT=""2""%SUBPATT=""1"";;%SUBPATT=""3""0%SUBPATT=""2""%SUBPATT=""1"";;%SUBPATT=""3""%SUBPATT=""2""0%SUBPATT=""1"";;%SUBPATT=""3""0%SUBPATT=""2""0%SUBPATT=""1"";;"%SUBPATT="1"
</regexp>

This regexp changes DD/MM/YYYY or DD-MM-YYYY to YYYYMMDD.

Note on my system, this is what I see:
%DATESHORT = 1/12/2001
<regexp>   = 20010121

Notice that my short date format does not match the DD/MM/YYYY format,
hence the wrong answer.  If I change my computer date to October 12,2001
the regexp spits out:

%DATESHORT = 10/12/2001
<regexp>   = 20011210

Perhaps that gives you a better example of what is really happening.

ND> Is this something easy to fix?

Although the description above is rather lengthy, it was fairly simple
to correct the problem.  Wait, I just noticed, this regexp will give
weird results when you have a two digit month and a 1 digit day.  I'll
have to think about this some more.

I'll get back to you if I figure out a solution.

-- 
Thanks for writing,
 Januk Aggarwal

 Using The Bat! 1.49
 under Windows 98 4.10 Build 2222  A 

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