[Home] [By Thread] [By Date] [Recent Entries]
Dear Liam,
Thanks for promoting the \b case. As an illustration for \b's usefulness, let me show how I tag acronyms for a recent project: <xsl:template match="text()" mode="majuscules"> <xsl:analyze-string select="." regex="(^|[\p{{P}}\p{{Z}}\p{{C}}])(\p{{Lu}}{{2,}})([\p{{P}}\p{{Z}}\p{{C}}]|$)"> <xsl:matching-substring> <xsl:value-of select="regex-group(1)"/> <span class="majusc"> <xsl:value-of select="regex-group(2)"/> </span> <xsl:value-of select="regex-group(3)"/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:template> With (a reasonably defined) \b, this could be simplified to <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>Please note that \b should not only match the \w/\W boundary, but also the beginning or end of the string (or line, when the 'm' flag is in force). Speaking of the 'm' flag, and in Michael's direction: I regard \b as much more useful than the 'm' flag when processing XML. Gerrit On 04.03.2010 06:59, Liam R E Quin wrote: 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
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler
|

Cart



