My understanding of .*? and its ilk is that they will match as little\nas is possible for the rest of the pattern to match, like .* will match\nas much as possible. In the first instance, the first (.*?) did not\nhave to match anything, because all of the rest of the pattern can be\nmatched 0 or more times. I think that such a situation (non-greedy\noperator followed by operators that match 0 or more times) will never\nmatch. However, in the second instance, it has to match something later\non in the string, so it will capture something.\n\nI believe that this is an operator precedence problem (greedy ? losing\nto .*?), but is to be expected. So, if this is the case, by all means\nit should be added in a note to the docs.\n\nHowever, I am not a regular expression expert, so my analysis of the\nsituation may be well off the mark.