The variable $incoming_data
contains escaped quotes, so you have to escape the backslash for the php regex pattern to match it.
Then your updated code would be:
$incoming_data = '<div id=\"title\">a title</div>';
$result = preg_replace('#<div id=\\\"title\\\">(.*?)</div>#', ' ', $incoming_data);
If you first want to strip the slashes from the string, you can use the stripslashes function.
Then your updated code would be:
$incoming_data = stripslashes('<div id=\"title\">a title</div>');
$result = preg_replace('#<div id="title">(.*?)</div>#', ' ', $incoming_data);
For the dom traversal you can use the DOMDocument class.