Regular Expression Example

These instructions transform dates of the form “12/8/2003” into ISO 8601 standard form: “2003-12-08”.

<xsl:analyze-string select="$date" 
     regex="([0-9]+)/([0-9]+)/([0-9]{{4}})">
  <xsl:matching-substring>
    <xsl:number value="regex-group(3)"
                format="0001"/>          
    <xsl:text>-</xsl:text> ...

Note that the curly braces are doubled in the regular expression. The regex attribute is an attribute value template, so to get a single “{” in the attribute value, you must use “{{” in the stylesheet.