preg_replace及其自动变量

While removing bugs from some PHP code, my browser shows me this error:

Parse error: syntax error, unexpected '1' (T_LNUMBER), expecting variable (T_VARIABLE) or '$' in (path)/functions.php on line 12

The line 12 of function.php is the following:

$file_id = preg_replace($regex,$1,$file);

and the regex defined by $regex is #^([0-9]*)\.markdown$#. I used preg_replace in other sites with the very same version of PHP (5.3). I tried to change $1 to \\1 or $$1 but it did nothing.

What is the point with this code? I don't understand.

Try this : use quote

$file_id = preg_replace($regex,'$1',$file);

You should use with qoutes "$1" like following:

$file_id = preg_replace($regex,"$1",$file);