Subject: [xsl] Re: efficiently extracting a capture group from analyze-string() From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 4 Jun 2022 17:22:10 -0000 |
Hi Gerrit, Graydon, Thanks for having a look! The tricky part is, I need an empty sequence if the input string does not comply with pattern. replace() returns the original string for a non-match. I could address that with a prefilter: replace($file[matches(., '/my-(\w+)\.xml$')], '^.+/my-(\w+)\.xml$', '$1') but I don't like duplicating patterns because they can accidentally become desynchronized. (If anyone suggests an ENTITY as a solution here, please see me after class.) Graydon, I need your solution for obtaining the file basename elsewhere in my stylesheet -- thank you!! -- but I run into the prefilter double-pattern issue whether I replace()the full path or just the basename. And although this example processes a filename, I'd like to find best generalized way to obtain a capture group (or nothing) for any match scenario. In perl, I can assign a variable to the result of a regex match: my $file = 'path/my-sometype.xml'; my ($type) = ($file =~ m{my-(\w+)}); and I was hoping for something similar in XQuery. Thank you everyone! It's nice to be able to group-think through this. - Chris XSL-List info and archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__ ;!!A4F2R9G_pg!YXd556WaLkP4pGQ6edPoLq22GVZWXz0FWKC8B6fG3pWIEv49hMn2JEHevovei-D Y16w5mb_F-bFG4sPyBrcYYJwk3mBc3dJ69yblgscpjoSpFqlrlsgk$> EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu b/xsl-list/3380743__;!!A4F2R9G_pg!YXd556WaLkP4pGQ6edPoLq22GVZWXz0FWKC8B6fG3pW IEv49hMn2JEHevovei-DY16w5mb_F-bFG4sPyBrcYYJwk3mBc3dJ69yblgscpjoSpFguJxHbP$> (by email<>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] efficiently extracting a , Graydon graydon@xxxx | Thread | Re: [xsl] Re: efficiently extractin, Imsieke, Gerrit, le- |
Re: [xsl] efficiently extracting a , Graydon graydon@xxxx | Date | Re: [xsl] Re: efficiently extractin, Imsieke, Gerrit, le- |
Month |