Re: [xsl] find capital letters in string and split it

Subject: Re: [xsl] find capital letters in string and split it
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 10 Feb 2003 11:18:35 GMT
> 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" 
<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


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:

 XSL-List info and archive:

Current Thread