$re = '/model: ([^\n]+)(.*)bitmap [^\n]+/ms';
$str = '# model: pmy0_footr015
filedependancy Unknown
newmodel pmy0_footr015
setsupermodel pmy0_footr015 NULL
classification Character
setanimationscale 1.0
beginmodelgeom pmy0_footr015
node dummy pmy0_footr015
parent NULL
endnode
node trimesh pmy0_footr015g
parent pmy0_footr015
position 0.0 0.0 0.0
orientation 1.0 0.0 0.0 0.0
bitmap pmh0_footr050
verts 15
-0.0378169 -0.00381612 0.00857995';
$subst = "model: $1$2bitmap $1";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php