Subject: Re: [xsl] Natural Sort From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 25 Jan 2006 14:31:34 GMT |
> It only works if all the numeric parts are one or two digits. > I can't think of an easy way of generalizing it, however. er yes, Also it fails if there are groups of digits too close to each other (as xpath regexp's don't have non-capturing groups so I need to pick up the non-digit either side of the number, so if there were two digit runs separated by a single letter it wouldn't match as the separating letter can't match twice. It's hard (or perhaps impossible) to to have a completely general rule but in any constrained case it's usually possible to come up with some regexp or other. For example if the example was as before, with just a single digit run, but extended to allow 1 2 or 3 digits then... <xsl:sort select="replace(replace(@dn,'([^0-9])([0-9][^0-9])','$10$2'),'([^0-9])([0-9]{2}[^0-9])','$10$2')"/> David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. 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 ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Natural Sort, cknell | Thread | Re: [xsl] Natural Sort, David Carlisle |
RE: [xsl] Natural Sort, Michael Kay | Date | Re: [xsl] Natural Sort, David Carlisle |
Month |