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

Subject: Re: [xsl] Sequence of chars not working with analyze-string
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Sun, 7 May 2006 12:17:23 +0100
Kent

I'm no expert but your regexp, (\d{7})\s+([0-9,]+)(.{30,60}), seems to match:
Seven digits followed by
some whitespace followed by
some digits or a comma followed by
any character at least 30 times, at most 60 times.
So if there are 60 characters it will match them all, if more than 30 but fewer than 60 you'll get all the characters.


--

Joe

----- Original Message ----- From: "Kent Seegmiller" <hookjaw20@xxxxxxxxxxx>
To: "XSLT" <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Sunday, May 07, 2006 10:07 AM
Subject: [xsl] Sequence of chars not working with analyze-string



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