non-matching-substring and matching-substring : analyze string « XSLT stylesheet « XML






non-matching-substring and matching-substring


File: Data.xml

<?xml version="1.0"?>
 
<start_date xmlns="http://www.java2s.com">1999-07-25</start_date>
File: Transform.xslt

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:analyze-string select="'&#x212A;'" regex="k" flags="i">
      <xsl:matching-substring>
        <xsl:text>It matches!</xsl:text>
      </xsl:matching-substring>
      <xsl:non-matching-substring>
        <xsl:text>It doesn't match!</xsl:text>
      </xsl:non-matching-substring>
    </xsl:analyze-string>
  </xsl:template>

</xsl:stylesheet>

Output:

It matches!

 








Related examples in the same category

1.analyze-string and regular expression
2.matching-substring