Subject: [xsl] Regex groups / was: Re: [xsl] Move leading/trailing spaces outside (XSLT 2.0) From: Yves Forkl <Y.Forkl@xxxxxx> Date: Tue, 06 Feb 2007 17:44:21 +0100 |
Please note the subtle differences between the above mentioned solution and the one I proposed. Both have their pros and cons. Depending on your final needs, one or the other may suit you best. Using [as the above mentioned solution suggested]
<xsl:analyze-string select="." regex="^(\s*)(.+?)(\s*)$">
will match the total string, so no need for using non-matching-substring. This has the advantage that you can do string-manipulation on the whole match at once, using regex-group(1), (2) and (3). If you only do string-replacement, your can optimize this with the replace() function.
Doing
<xsl:analyze-string select="." regex="^\s+|\s+$">
is quicker, has the advantage of separating logic, but has the disadvantage that you cannot intermix the matching and non-matching strings (meaning, when you are in non-matching-substring, it contains the non-space content of your match, and you cannot get the matching-substring from that instruction and vice versa).
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Move leading/trailing spa, Abel Braaksma | Thread | Re: [xsl] Regex groups / was: Re: [, Abel Braaksma |
Re: [xsl] Move leading/trailing spa, Abel Braaksma | Date | Re: [xsl] "Market"-Share of XSLT pr, Mukul Gandhi |
Month |