On 10/06/2012 07:46, Syd Bauman wrote:
But is there any reason not to use a simpler regex? E.g.,
<xsl:analyze-string select="normalize-space($title)" regex="(.+) - (.+)">
Even if it doesn't fix your problem, it might make it easier to find.
I think this principle of always using the simplest regex that does the
job is a very good one. Remember, even if the regex works on all your
test cases, there's a good chance someone in a year's time is going to
come back to it and need to change it. Complex regexes are intrinsically
very hard to debug, so it's a good idea to avoid them if you can.
In this particular case the simpler regex is also closer to the
English-language description of the requirement:
separate the content after the last "space dash space"
The OP's regex fails to do this if, for example, the content after the
last " - " includes a hyphen.
Michael Kay
Saxonica
--~------------------------------------------------------------------
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>
--~--