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

Regular expression to exclude files

Subject: Regular expression to exclude files
From: "Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Feb 2023 20:30:32 -0000
 Regular expression to exclude files
Im using Saxons collection() extension that lets you specify a regular
expression to select files within a directory. These are XPath regular
expressions so my question is I think a general XPath question.

I want to match all files with a given extension except those that start with
foo or bar.

I think the Perl expression would be something like:

.*?!(foo|bar).+.ditamap


Using this little XQuery:

let $strings as xs:string* := ('bundle-aaaa.ditamap',
'publication_pub-one.ditamap', 'not-pub-or-bundle.ditamap', 'atopic.dita')
return
count($strings[matches(., '.?!(bundle-|publication_).+\.ditamap')])


I get zero results, while this:

let $strings as xs:string* := ('bundle-aaaa.ditamap',
'publication_pub-one.ditamap', 'not-pub-or-bundle.ditamap', 'atopic.dita')
return
count($strings[matches(., '.+\.ditamap')]

Returns the expected 3

Reading the XSD regular expression spec I did not see an obvious way to
specify this kind of negative match but I also find the XSD specification to
be almost impenetrably difficult to decode.

Is there a way to do this with regular expressions alone?

I want a pure regex solution because Im using it in the context of an Oxygen
xpath_eval() call so its not easy (but not impossible) to filter the files
returned by the collection() call (Im using the metadata=yes form since I
want the file names, not the parsed docs in this context).

Thanks,

E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> |
Twitter<https://twitter.com/servicenow> |
YouTube<https://www.youtube.com/user/servicenowinc> |
Facebook<https://www.facebook.com/servicenow>

Current Thread

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
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.