W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2003

RE: Patterns and Decimal

From: Paul Warren <pdw@decisionsoft.com>
Date: 27 Feb 2003 16:11:29 +0000
To: Anli Shundi <ashundi@tibco.com>
Cc: "'daniella d'" <daneladg@yahoo.co.uk>, xmlschema-dev@w3.org
Message-Id: <1046362289.4260.96.camel@tobol.dsl.local>

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.
> 
>   <xsd:pattern value = "[0-9][\.][0-9]*"/> 
>   <xsd:pattern value = "[1-9][0-9]*[\.][0-9]*"/>
>   <xsd:pattern value = "[1-9][0-9]*"/>
> 
> 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
Received on Thursday, 27 February 2003 11:11:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:36 GMT