> I am assuming my the problem is with ,?
> But I don't understand why.

> (\d+,?\d+\.?\d+)

This matches 1+ digits, and optional comma, 1+ digits, optional period, and
1+ digits.

So if the comma is not present (which it isn't in your example) it MUST
match AT LEAST TWO digits (one before AND one after the optional comma)...
and your data only has a single digit.

What you want is this (or something similar)...

[extra whitespace added for clarity]
( (?:\d+,)? (?:\d+\.)? \d+ )

This matches an optional digits-and-comma, an optional digits-and-period,
followed by one or more digits.  So 123 will match, 1.23 will match, 1,23
will match, and 1,2.3 will match.

The (?: ... ) syntax groups (like parens) but doesn't trap (doesn't save
into $1, $2, etc).

Hope that helps.

Rob


-----Original Message-----
From: Paul Kraus [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 2:49 PM
To: [EMAIL PROTECTED]
Subject: Why doesn't this match


Expression
/Sales - Freight - Leimkuehler\s+(\d+,?\d+\.?\d+)/

String
410-02-00        Sales - Freight - Leimkuehler
6.96

It does match if I remove everything after Leimkuehler.
This is how it reads to me

1 or more spaces
Open paren to save value to $1
1 or more digits
Maybe a comma but not necessary
1 or more digits
Maybe a period but its not necessary.
1 or more digits

I am assuming my the problem is with ,? But I don't understand why.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to