|
Subject: Re: [xsl] xsl:analyze-string explanation needed From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 20 Jul 2006 14:30:46 +0100 |
> Looking at it, I see the general form as:
>
> Compare the string to the regular expression.
> If there is a match, output something.
> If there is no match, output something else.
Nope.
Compare the string to the regular expression.
find _each_ (non-overlapping) substring that matches the regexp.
this gives you a sequence of substrings that alternate
matching,non-matching,matching,..
for each item in this sequence, execute the matching or non-matching
branch of the code.
so...
> Given the input "3 minutes 57 seconds",
([0-9]+ minutes) matches just once so you get the sequence of strings
("3 minutes","57 seconds")
so execute xsl:matching-substring with . set to "3 minutes"
producing 180
then execute xsl:non-matching-substring> with . set to "57 seconds"
producing 0
think of doing a regexp replace of a large text and changing all "white"
to "black"
analyze sequence splitsthe text up to a sequnce of strings, that are
alternately "white" or <the stuff betwwen matches>. Your two brances
would then output "black" in the matching case and do a copy-of in the
non matching case and the end result is all occurrences of white get
changed to black.
David
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] xsl:analyze-string explanatio, cknell | Thread | Re: [xsl] xsl:analyze-string explan, David Carlisle |
| [xsl] xsl:analyze-string explanatio, cknell | Date | Re: [xsl] Having problem matching r, Dimitre Novatchev |
| Month |