[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] invalid escape sequence: \b


Subject: RE: [xsl] invalid escape sequence: \b
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 29 Sep 2008 21:25:43 +0100

The \b escape sequence is not available in the regex dialect defined for use
in the XML Schema and XPath/XSLT specifications. I think the reason for this
is that the concept of a "word boundary" is too difficult to define in a
language-independent way. 

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Tony Zanella [mailto:tony.zanella@xxxxxxxxx] 
> Sent: 29 September 2008 20:49
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] invalid escape sequence: \b
> 
> Hello all,
> I'm using oXygen 9.3 to write a template that uses a regular 
> expression as an argument for the xslt function matches().  
> While writing the regex, I used oXygen's onboard find/replace 
> with the option for regular expression selected to test for 
> what I wanted. I managed to get the following regex working 
> on some test data:
> 
> [IVXMDC]\b
> 
> For example, given the following three lines:
> 
> VI
> Pt. XXIV
> Chapter II. CHARITABLE EFFORT
> II: England
> 
> The regex matches on all and only the roman numerals when I 
> just use oXygen's find/replace.
> 
> But when I try to plug this into an xsl instruction:
> 
> <xsl:if test="not(matches(.,'[IVXMDC]\b'))">
>          <xsl:value-of select="lower-case(.)"/>
>       </xsl:if>
> 
> I get the following error:
> 
> Description: Error at character 10 in regular expression
> "[IVXMDC]+\b": invalid escape sequence
> 
> ...and running the template breaks things. Searching the 
> forums, I found this thread:
> 
> http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/a
> rchives/200801/msg00304.html
> 
> from which I gathered that I might try to remove the 
> backslash and see if the transformation worked. But doing 
> that didn't work. Nor did escaping the backslash with another 
> backslash.
> 
> Thanks in advance for any tips. And sorry if this isn't the 
> right forum for this post.
> Tony


Current Thread