Subject: Re: 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"
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 |
bryan - Mon, 10 Feb 2003 05:54:09 -0500 (EST)
- David Carlisle - Mon, 10 Feb 2003 06:17:22 -0500 (EST) <=
- bryan - Mon, 10 Feb 2003 06:53:30 -0500 (EST)
- Francis Norton - Mon, 10 Feb 2003 06:27:40 -0500 (EST)
|
|