Ok
I have had this exact same proiblem. And after going though the dam manual and reading up on it i got an explanasion on the error. By default regular excpressions are greedy in matching their stuff. So it will go though the document and match it 2 it cant match it any more. Thus it goes to the very end and takes out everything inbetween you start clause and end clause(last match).
By default, the quantifiers are "greedy", that is, they
match as much as possible (up to the maximum number of permitted
times), without causing the rest of the pattern to
fail. The classic example of where this gives problems is in
trying to match comments in C programs. These appear between
the sequences / and / and within the sequence, individual
* and / characters may appear. An attempt to match C comments
by applying the pattern
/\*.*\*/
to the string
/* first command */ not comment /* second comment */
fails, because it matches the entire string due to the
greediness of the .* item.
However, if a quantifier is followed by a question mark,
then it ceases to be greedy, and instead matches the minimum
number of times possible, so the pattern
/\*.*?\*/
does the right thing with the C comments. The meaning of the
various quantifiers is not otherwise changed, just the preferred
number of matches. [/I]
That is fromt he manual.
Now the problem i had was this just spat out errors for me. But their is the section from PHP manual. Find it and read up might work for u