[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mobile phone numbers
- From: Eddie Robertsson <eddie@allette.com.au>
- To: priscilla@walmsley.com
- Date: Sat, 08 Sep 2001 16:38:19 +1000
Priscilla Walmsley wrote:
> Close, but there are a couple problems:
>
> - You should use parentheses instead of angle brackets
> - The + needs to be escaped
> - I'm assuming it's the group "04" that's optional, not just the "4". So
> you have to put the 04 in parentheses. Likewise for the +614.
> - There seem to be 8 digits after the +614 number, not 7.
>
> Try this:
> ((04)?[0-9]{8}) | ((\+614)?[0-9]{8})
This looks like the correct regular expression for what you need and my
suggestion is probably just a personal preference but if you have pattern
groups that are OR:ed together I find it much easier to read if they are in
separate pattern elements. So, in the case above I would write the type as:
<xs:simpleType name="phoneType">
<xs:restriction base="xs:string">
<xs:pattern value="(04)?[0-9]{8}"/>
<xs:pattern value="(\+614)?[0-9]{8}"/>
</xs:restriction>
</xs:simpleType>
Since, multiple pattern elements are OR:ed together the result will be the
same.
Cheers,
/Eddie
>
>
> I think that should work.
>
> Priscilla
>
> -----------------------------------------------------------
> Priscilla Walmsley priscilla@walmsley.com
> Architect, Vitria Technology http://www.vitria.com
> Author, Definitive XML Schema (Prentice Hall, Dec. 2001)
> -----------------------------------------------------------
>
> > -----Original Message-----
> > From: topper harley [mailto:bicepmaximus@hotmail.com]
> > Sent: Friday, September 07, 2001 1:40 AM
> > To: xml-dev@lists.xml.org
> > Subject: Mobile phone numbers
> >
> >
> > Hi,
> > i wanted to write a pattern value string that reads in
> > a mobile phone
> > number of the pattern 0412867576 or +61412867576 only. At
> > the moment i am
> > using this check
> >
> > <xsd:simpleType name="Mobile">
> > <xsd:restriction base="xsd:string">
> > <xsd:pattern value="<04?[0-9]{8}> | <+614?[0-9]{7}>"/>
> > </xsd:restriction>
> > </xsd:simpleType>
> >
> > is this correct or any help would be great!
> >
> > Topper
> >
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at
> > http://explorer.msn.com/intl.asp
> >
> >
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > initiative of OASIS <http://www.oasis-open.org>
> >
> > The list archives are at http://lists.xml.org/archives/xml-dev/
> >
> > To subscribe or unsubscribe from this elist use the subscription
> > manager: <http://lists.xml.org/ob/adm.pl>
> >
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this elist use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>