Hi there, I'm pretty new to PHP and regular expressions in general, but I've got a question that's sort of bothering me. Suppose I have the following input:
$t = "[start] data1 [end][start] data2 [end]";
If I do a preg_replace like this:
$pattern = array("/start[end]/");
$replace = array("[start]<b>\1</b>[end]");
preg_replace($pattern, $replace, $t);
My understanding is that it would put everything between the FIRST [start] and the LAST [end] in bold because it goes for the largest match on the input. What I want though is the shortest match. How do I construct the pattern so that it'll match each set of [start][end] and do the replace on what's in the middle? In the above case "data1" and "data2" should be bold separately.
Thanks a lot for your help...