|
Subject: Re: [xsl] Regex in @select Escaping Puzzle From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 16 Aug 2020 15:52:50 -0000 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Regex in @select Escaping Puz, Eliot Kimber ekimber | Thread | Re: [xsl] Regex in @select Escaping, Martin Honnen martin |
| [xsl] Regex in @select Escaping Puz, Eliot Kimber ekimber | Date | Re: [xsl] Regex in @select Escaping, Martin Honnen martin |
| Month |