Or strip all existing occurrences of allowscriptaccess="never" out of any embed tags that contain it, and then you won't have to check it's there when you're putting it in.
In fact, you'd want to strip all occurrences of "allowscriptaccess" attributes, whatever their value, won't you? Don't forget, too, that there can be whitespace between the = and the attribute name and/or value. To deal with different quoting styles it may be easier to deal with ", ' and separately - so that's three expressions. Which I think are
#<embed([^>]*)allowscriptacess\s*=\s*'[^']*'([^>]*)>#i
#<embed([^>]*)allowscriptacess\s*=\s*"[^"]*"([^>]*)>#i
and finally
#<embed([^>]*)allowscriptacess\s*=\s*[^ >]*([^>]*)>#i
each replaced with
<embed$1 $2>
After that it's trivial to just put 'allowscriptaccess="never"' into all <embed> tags.
What would also be simpler (at least, in PHP5) would be to use the DOM extension:
$doc = @DOMDocument::loadHTML($string);
$embed_tags = $doc->getElementsByTagName("embed");
for($i=0; $i<$embed_tags->length; ++$i)
$embed_tags->item($i)->setAttribute("allowscriptaccess","never");
echo $doc->saveHTML();
Two drawbacks: since <embed> is not a valid HTML tag, the loadHTML() method needs to have its error messages suppressed with @; and the output HTML ends up with additional tags added so that the string is valid HTML. Well, three drawbacks: it assumes the input is HTML, not text with a few HTML tags thrown in....