Re: [xsl] Syntax error in regex pattern

Subject: Re: [xsl] Syntax error in regex pattern
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 13 Jul 2019 16:45:21 -0000
On Sat, Jul 13, 2019 at 04:32:39PM -0000, Scott Vanderbilt lists@xxxxxxxxxxxxx scripsit:
>     <xsl:analyze-string select="$stringtoproc" regex="\p{L}">

It's usually safest to use the pattern:

<xsl:variable name="search" as="xs:string" select="'\p{L}'"/>
<xsl:analyze-string select="$stringtoproc" regex="{$search}">

because otherwise you have to remember the parsing rules the regex attribute is using.  ("Do I have to double the braces to escape them?, etc.)  I can never quite manage to do that, so putting the regular expression in a string variable is just easier.

In the specific case, because the regex attribute accepts attribute value templates, the braces are going to have the AVT meaning unless escaped.

-- Graydon

Current Thread