Originariamente inviato da gm
Basta mettere un bel quantificatore not greedy (oltre a un bel po' di backslash):

$mess = preg_replace("/\[IMG\](.*?)\[\/IMG\]/i", "<img src=\"\\1\">",$mess);
potresti spiegarmi meglio cosa fa quella i in fondo ?

perche' poi metti (.*?) ?



U (PCRE_UNGREEDY)

This modifier inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by "?". It is not compatible with Perl. It can also be set by a (?U) modifier setting within the pattern.
:master: