With the help of Michael Kay, I can answer my own question. Thanks Michael! The solution works, but in my opinion, these long Unicode ranges do not look very pretty.
This XSLT will print a text message if any Chinese character was found with regular expressions in this XML:
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/root/node"> <xsl:if test="matches(.,'[一-鿿㐀-䷿𠀀-𪛟豈-﫿丽-𯨟]')"> <xsl:text>Text has chinese characters!</xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet>
Solution with a Unicode named block:
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/root/node"> <xsl:if test="matches(., '[\p{IsCJKUnifiedIdeographs}\p{IsCJKUnifiedIdeographsExtensionA}\p{IsCJKUnifiedIdeographsExtensionB}\p{IsCJKCompatibilityIdeographs}\p{IsCJKCompatibilityIdeographsSupplement}]')"> <xsl:text>Text has chinese characters!</xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet>
source share