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

Re: find capital letters in string and split it

Subject: Re: find capital letters in string and split it
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 10 Feb 2003 11:18:35 GMT
find uppercase
> Let's suppose I want to split the string at the upper case letters, the
> easiest way I can see to do that (the only way that pops into my mind)
> is to parse the string twice, using translate() and replacing upper-case
> letters with a string sequence not very likely to occur normally, and
> then reparse the string splitting it at these occurrences. This is of
> course resource intensive and not foolproof. Anybody have any thoughts
> on how to do this?

still slow but you can avoid the "not very likely to occur" problem by
first translating all uppercase to (say) A then using substring-before
to split on A then using substring

so if $x is your original string
<xsl:variable name="y" 
  select="translate($x,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','AAAAAAAAAAAAAAAAAAAAAAAAAA')"/>
<xsl:if test="contains($y,'A')">
<xsl:variable name="a" select="substring-before($y,'A')"/>
first bit = <xsl:value-of select="$a"/>
second bit = <xsl:value-of select="substring-after($x,$a)"/>
  recurse using $x='second bit' to split up further f necessary

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.