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

Re: efficiently extracting a capture group from analy

Subject: Re: efficiently extracting a capture group from analyze-string()
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 4 Jun 2022 16:33:19 -0000
Re:  efficiently extracting a capture group from  analy
On Sat, Jun 04, 2022 at 12:22:49PM -0400, Graydon Saunders scripsit:
> I would recommend against trying to do this with general application of
> a single regular expression.

and I still would, but now I've read your question a little slower and
you want the bit after the dash but before the suffix.

file:name($file) => replace('my-','') => replace('.xml','')

but this gives me the flinch because I don't necessarily trust file
names to be consistent.  You could add 'i' to the replace, or

file:name($file) => tokenize('[\.-]')[not(matches(.,'my','i') or
matches(.,'xml','i'))]

Might be a little more robust against future change since you can add
individual tests to the predicate.

For real it could be

file:name($file) => tokenize('[\.-]') ! local:wantedFileNamePart(.)

where local:wantedFileNamePart() knows the rules for what parts to keep.

This gives you the opportunity to deal with the file names you have to
put back together if there's inconsistency in the pattern such as
"my-long-name.xml".

-- 
Graydon Saunders  | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

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.