$re = '/IOCP\.sendVarData\(\s*(\d+)\s*,\s*\(int\)sPmdgData\.MCP_(\w+)\);/';
$str = 'IOCP.sendVarData(1374, (int)sPmdgData.MCP_FPA);
IOCP.sendVarData(100, (int)sPmdgData.MCP_ABC);';
$subst = "if((int)sPmdgData.MCP_\2) != T7X_MCP_\2)\n{\n\tT7X_MCP_\2 = sPmdgData.MCP_\2;\n\tIOCP.sendVarData(\1, T7X_MCP_\2);\n}\n";
$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