$re = '/(?<spaceBefore>^[ \t]*)(?<function>SetColor|SetAlpha|DrawRect|Delay|Flip|SetScale|SetVirtualResolution|CloseStream)[ \t]*(?!\()(?<parameters>[\w \(\)\-,\.\/\[\]\*\t\+]+)?;?/m';
$str = '
DrawRect barX-2 ,barY-2 ,barW+4 ,barH+4 ;
SetColor rgb[0]*colorMultipler,rgb[1]*colorMultipler,rgb[2]*colorMultipler;
public static TImage DelayTimer_in=BM
SetAlpha - float(n) / Fade1 //nn
DrawRect 0, 0,tApplication.ScrW(),tApplication.ScrH();
SetVirtualResolution(SourceScreenWidth, SourceScreenHeight);
SetColor 0, 0, 0
Delay 10; //mmm
Flip;
SetScale 10, 10;
CloseStream tLog.file;
';
$subst = "$1$2\($3\);";
$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