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

Re: Regex in @select Escaping Puzzle

Subject: Re: Regex in @select Escaping Puzzle
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 16 Aug 2020 15:52:50 -0000
Re:  Regex in @select Escaping Puzzle
The XSD regex rules require '}' to be escaped as `\}`, even though there's not
really any ambiguity.

I would also suggest using `[^}]+` in place of `.+` to reduce the amount of
backtracking needed.

So

> \{\{image_[^}]+\}\}([^{]+)\{\{/image\}\}

Michael Kay
Saxonica

> On 16 Aug 2020, at 16:42, Eliot Kimber ekimber@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> I have this element as my context element:
>
> <p>{{image_100}}GEO_AS_MC_M01_T02_05.eps{{/image}}</p>
>
> And I want to get the "GEO_AS_MC_M01_T02_05.eps" using analyze-string, where
the value "image_100" could have any value where "100" is in this example.
>
> I can't work out the way to escape the curly braces in the @regex value so
my match works (or I can't work out what else I might be doing wrong).
>
> Oxygen's regex search gives me the correct result with this:
>
> \{\{image_.+}}([^{]+)\{\{/image}}
>
> But this attempt in XSLT 3 does not work:
>
> <xsl:analyze-string select="."
regex="\{{\{{image_.+}}(.+)\{{\{{/image}}}}">
>
> In that the non-matching substring is the entire selected string,
> o;?
> What regex or escaping detail am I missing?
>
> Thanks,
>
> E.
>
> --
> Eliot Kimber
> http://contrext.com

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.