xsl-list
[Top] [All Lists]

Re: Natural Sort

2006-01-25 07:31:34

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
________________________________________________________________________

--~------------------------------------------------------------------
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>