[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML Schemas: Regular Expression Question

  • From: tpassin@h...
  • To: "Roger L. Costello" <costello@m...>, xml-dev@l...,xerces-j-dev@x...
  • Date: Sun, 03 Sep 2000 18:35:54 -0400

champion gif
 Roger L. Costello asked -

> Consider this regular expression:
>
> (.)+\.(gif|jpg|jpeg|bmp)
>
> As I interpret this regular expression it says, "one or more occurrences
> of any character, followed by a dot, followed by either gif or jpg or
> jpeg or bmp".  Correct?
>
> Here's my question - why is it that two schema validators (Oracle and
> xerces 1.2) both accept the following strings:
>
> images\mighty_oj.gif
> images\omega.jpg
> images\wheateena.jpg
>
> but reject these strings:
>
> images\champion.gif
> images\greenPower.jpg
> images\juiceman.jpg
>
I'm not sure if it's the same in xml schemas, but try this version:

(.+)\.(gif|jpg|jpeg|bmp)

In python, the original expression matches the last character of the name,
as well as returning the extension (since it is in parentheses).  The new
version matches correctly - at least, in python:

import re
patre=r".+\.(gif|jpg|jpeg|bmp)"
pat=re.compile(patre)

print pat.findall(r'images\champion.gif')
>>> [('n', 'gif')]

# New version
patre=r"(.+)\.(gif|jpg|jpeg|bmp)"
 pat=re.compile(patre)

print pat.findall(r'images\champion.gif')
>>>[('images\\champion', 'gif')]

Cheers,

Tom Passin


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.