RE: [xsl] Sequence of chars not working with analyze-string

Subject: RE: [xsl] Sequence of chars not working with analyze-string
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 7 May 2006 13:56:15 +0100
> I am trying to parse a text doc using analyze-string.  But
> when I want to retrieve the 30th to 60th chars it ignores the
> first arg and retrieves the second.  For example (.{{30,60}})

.{30,60} matches any sequence of characters with a minimum length of 30 and
a maximum length of 60, and generally speaking unless specified otherwise a
regular expression will match the longest sequence of characters it can.

So it's clear why it's doing what it does. I don't have time right now to
suggest what you should be doing instead.

Michael Kay
http://www.saxonica.com/

> returns 60 chars.
> Here is the source:  "Daily Appointments.txt"
>       Consignee:  FARR WEST - DELI
>       Start Time    Stop Time        Load ID  Order #
> Carrier     Cases
> Weight  Pallets     Cube  Vendor Name                   Load Type
>
>       04/01/06 06:00 04/01/06 07:30  300559               PFS*
> Door:311D Con:0104                    StrrmLnCPU HOT
>                                                9856065
>         1,800
> 36,000      56      1,821PROFESSIONAL FOOD SYSTEMS     (   (  (
>                                                      Load
> Totals      1,800
> 36,000      56      1,821
>
>       04/01/06 06:00 04/01/06 07:30  300382               DON
> STOCKLEY
> TRUCKING             Door:317D Con:0104
> StrrmLnCPU HOT
>                                                9865900
>           206
> 2,650      11        253KINGS HAWAIIAN BAKERY         (   (  (
>                                                9872940
>             5
> 3,780       5        270AMERICAN PIE                  (   (  (
>
>                                                9877320
>           290
> 1,813       2         86SAPUTO CHEESE USA INC         (   (  (
>                                                9880590
>           450
> 6,831       6        298AMERICAN PIE                  (   (  (
>
>
>                                                           (   (  (
>                                                9880600
>           418
> 4,828      10        347CLAIM JUMPER RETAIL FOODS
>                                                9886650
>           282
> 3,036       4        145SPECIALTY BRANDS              (   (  (
>
>                                                      Load
> Totals      1,651
> 22,938      38      1,399
>       04/01/06 06:00 04/01/06 07:30  300166               AFS
> Door:319D Con:0104                    StrrmLnCPU HOT
>                                                9873530
>           630
> 4,095       6        180LAYTON DAIRY                  (   ~  (
>
>
>                                                           (   ~  (
>                                                9880740
>         1,008
> 6,300      10        297LAYTON DAIRY
>
> Using the following
> ...
>    <xsl:for-each select="tokenize(unparsed-text('Daily
> Appointments.txt'),'\r\n')">
>    <xsl:analyze-string select="."
> regex="(\d{{7}})\s+([0-9,]+)(.{{30,60}})">
>    <xsl:matching-substring>
>    <load>
>    <po><xsl:value-of select="regex-group(1)"/></po>
>    <cases><xsl:value-of
> select="replace(regex-group(2),',','')"/></cases>
>    <vendor><xsl:value-of select="regex-group(3)"/></vendor>
>    </load>
>    </xsl:matching-substring>
>    </xsl:analyze-string>
>    </xsl:for-each>
> ...
>
> I am trying to retrieve the PO, cases, and vendor name.
>
> Thanks for the help

Current Thread