In your regex the forward slash is the regex delimiter. As you are dealing with tags, better use another delimiter (instead of escaping it with a backslash):
$matches = preg_replace("#<object(.+?)</object>#", "replacing string", $str);
There are other delimiteres, too. You can use any non-alphanumeric, non-backslash, non-whitespace character. However, certain delimiters should not be used under any circumstances: |
, +
, *
and parentheses/brackets for example as they are often used in the regular expressions and would just confuse people and make them hate you.
Btw, using regular expressions for HTML is a Bad Thing!