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

Re: Syntax error in regex pattern

Subject: Re: Syntax error in regex pattern
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 13 Jul 2019 16:45:21 -0000
Re:  Syntax error in regex pattern
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


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.
First Name
Last Name
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.