xsl-list
[Top] [All Lists]

Re: [xsl] Formatting string

2007-05-16 05:45:34
Joe Fawcett wrote:
The trouble with these is that they don't cope with expressions such as "UKBank" or "BankOfUSA". I'm trying to come up with a neat expression that does.

The trouble is that I put the space on the wrong position. I was thinking of the double capitals and it is of course easily fixed, but I didn't know the requirements well enough. For instance: "AStringToPutAFewSpacesIn" is going to give you trouble anyway:

<xsl:value-of select="replace('BankOfUSA', '(.)([A-Z]+)', '$1 $2')" />

or, perhaps prettier:
<xsl:value-of select="normalize-space(replace('BankOfUSA', '[A-Z]+', ' $0'))" />

both will output: "Bank Of USA"

Cheers,
-- Abel Braaksma



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>