|
Subject: [xsl] Regular expression to exclude files From: "Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 16 Feb 2023 20:30:32 -0000 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Followup question: was Re: [xsl, ohaya ohaya@xxxxxxxx | Thread | Re: [xsl] Regular expression to exc, David Carlisle d.p.c |
| Followup question: was Re: [xsl] XS, ohaya ohaya@xxxxxxxx | Date | Re: [xsl] Regular expression to exc, David Carlisle d.p.c |
| Month |