Subject: Re: [xsl] lookaheads in XSLT2 regexes From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Thu, 04 Mar 2010 18:12:09 +0100 |
<xsl:template match="text()" mode="majuscules"> <xsl:analyze-string select="." regex="\b\p{{Lu}}{{2,}}\b"> <xsl:matching-substring> <span class="majusc"> <xsl:value-of select="."/> </span> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:template>
On Wed, 2010-03-03 at 21:27 +0000, Michael Kay wrote:On the subject of \b I'll note we do have \W and \w
So we do, I overlooked that. And we define it a little differently from Perl:
[#x0000-#x10FFFF]-[\p{P}\p{Z}\p{C}]
So for example "+" is regarded as part of a word, while "-" isn't. Which strikes me as totally useless, to be honest.
I agree.
We could fix that for XPath 2.1 I think. I'm not sure what the most useful fix would be, I admit.
The Perl definition of "alphanumeric" plus "_" would probably work for \w, if one took alphnumeric to mean Letters|Numbers, \p{L}|\p{N}, and is coincidentally closer to what you get in Perl if you do use locale; and your locale is (say) en_UK.UTF8, as it's then the same as the POSIX fragment [[:alpha:][:digit:]_]
There are lots of things that could be added to regular expressions; but \b is hard to emulate, useful, and also we seem to have a rather odd \w. If \w is there, I think \b was omitted by mistake. Or that \w was included by mistake!
Liam
-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930
Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] lookaheads in XSLT2 regex, Liam R E Quin | Thread | RE: [xsl] lookaheads in XSLT2 regex, Michael Kay |
RE: [xsl] same content refuses to c, Michael Kay | Date | RE: [xsl] lookaheads in XSLT2 regex, Michael Kay |
Month |