yes..... that regex matches the entire table.... it will replace the entire string with $replace.
what is it you want to replace?
You could use capturing replacement...
preg_replace("/(<table.*?>).*(<\/table>)/","\$1$replace\$2},$str);
Or you could use a non-capturing group around the parts to not replace...
e.g.
preg_replace("/(?:<table.*?>).*(?:<\/table>)/",$replace,$str) //not tested, though
EDIT in response to OP change
preg_replace("/<table.*?>/",$replace,$str);
You wanted to use lazy capturing *?