[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: regexp question

Subject: RE: regexp question
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Sun, 12 Sep 2004 18:58:28 +0100
regex d
A repetition count in a regex is indicated by curly braces, not square
brackets. Remember also that in an attribute value template, curly braces
must be doubled. So you want:

regex='(\d{{4}})(\d{{2}})(\d{{2}})'

Alternatively, you could just as well use

regex='(....)(..)(..)'

Some people might argue that regular expressions are overkill for this task
and you should use concat() and substring() - but that's an area where
opinions may differ.

Michael Kay
 

> -----Original Message-----
> From: Bruce D'Arcus [mailto:bdarcus@xxxxxxxxxxxxx] 
> Sent: 12 September 2004 15:58
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  regexp question
> 
> Using XSLT 2.o, I want to take this:
> 
> 	<meta name="pdate" content="20001123"/>
> 
> .... and get this:
> 
> 	<meta name="dateIssued" content="2000-11-23"/>
> 
> Why isn't the following pattern matching (in the xhtml:meta 
> template), 
> and is there a better way?
> 
>      <xsl:when test="@name='pdate'">
>        <xsl:analyze-string select="@content" 
> regex='(\d[4])(\d[2])(\d[2])'>
> 	<xsl:matching-substring>
> 	  <meta name="dateIssued">
> 	    <xsl:attribute name="content">
> 	      <xsl:value-of select="regex-group(1)"/>
> 	      <xsl:text>-</xsl:text>
> 	      <xsl:value-of select="regex-group(2)"/>
> 	      <xsl:text>-</xsl:text>
> 	      <xsl:value-of select="regex-group(3)"/>
> 	    </xsl:attribute>
> 	  </meta>
> 	</xsl:matching-substring>
> 	<xsl:non-matching-substring>
> 	  <meta name="dateIssued" content="{.}"/>
> 	</xsl:non-matching-substring>
>        </xsl:analyze-string>
>      </xsl:when>
> 
> Bruce

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.