Forum Moderators: coopster
$str = 'a string with 2 {gallery=/path/to/images/} paths in it {gallery=/second/path/to/images/} to test with';
$imgStart = '<img src="';
$imgEnd = '" alt="picture" title="">';
//the replacement pattern says:
//find {gallery= then capture everything up til a right brace- '}'
//RegExp "$1" will be the captured () part
$replacedString = preg_replace("/\{gallery=([^\}]+)\}/", $imgStart."$1".$imgEnd, $str);
echo '<br>'.$replacedString;
/*** viewing source will show:
<br>a string with 2 <img src="/path/to/images/" alt="picture" title=""> paths in it <img src="/second/path/to/images/" alt="picture" title=""> to test with
***/