xsl-list
[Top] [All Lists]

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

2007-02-06 10:02:32
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


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