RE: Patterns and Decimal

Thanks. I rewrote the expessions as you suggested and it now works fine. The regular expession  (0(\.[0-9]{0,3})|[1-9][0-9]*(\.[0-9]+)?) checks all the cases.
daniella
 Paul Warren <pdw@decisionsoft.com> wrote:On Thu, 2003-02-27 at 15:42, Anli Shundi wrote:
> I think the regular expressions should be rewritten
> to escape the dot, i.e.
> 
> 
> 
> 
> 
> If the dot is unescaped it matches any character,
> thus "[0-9][.][0-9]*" matches 0123.

No. "[.]" is a perfectly valid way to match a literal ".". See:

http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#nt-charRange

It is equivalent to "[\.]" and to "\.".

Personally, I'd write it as (0\.[0-9]*|[1-9][0-9]*(\.[0-9]*)?)

but in fact, I'd probably want: (0(\.[0-9]+)?|[1-9][0-9]*(\.[0-9]+)?)

as this allows "0", but forbids "0." and "123." etc.

Paul





---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs

Received on Friday, 28 February 2003 03:46:25 UTC