Re: [xsl] XSLT Regex for Matching Curly Braces

Subject: Re: [xsl] XSLT Regex for Matching Curly Braces
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Jun 2019 17:21:09 -0000
> On 10 Jun 2019, at 17:56, Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> If you want to use xsl:analyze-string with XSLT 2.0 (or 3.0), you can put
the regex in a variable, like so:
>
>
>  <xsl:variable name="regex" as="xs:string" select="'\{([^}]+)\}'"/>

I think it's even clearer to use

> <xsl:variable name="regex" as="xs:string"
expand-text="no">{([^}]+)\}</xsl:variable>
>

This way you avoid complications with single and double quotes as well as
curly braces: the only characters that now have an XML or XSLT-defined special
meaning are "&" and "<", and these fortunately don't have special meanings in
regular expressions.

Michael Kay
Saxonica

Current Thread