Re: [xsl] Regex groups / was: Re: [xsl] Move leading/trailing spaces outside (XSLT 2.0)

Subject: Re: [xsl] Regex groups / was: Re: [xsl] Move leading/trailing spaces outside (XSLT 2.0)
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 06 Feb 2007 18:00:58 +0100
Abel Braaksma wrote:

regex: (t)|(.)


will put all 't' in regex-group(1) and all other chars in regex-group(2).


forgot to mention: the rules of greediness are interesting in this last example. Suppose you turn it around:


regex: (.)|(t)

now, you may thing that regex-group(1) contains all other chars and regex-group(2) will contain all 't' characters. Alas, this is not so. Though regex-group(2) exists and will not raise an error (luckily), it will never match anything, i.e., will always be empty. This is because the greediness rules will match (.) for everything, including any 't' character, succeeding before right away. So, the above acts the same as:

regex: (.)


Cheers, -- Abel Braaksma

Current Thread