RegExp Replace if not Input/Textarea

I need help writing a regular expression that would replace all instances of an email, but not the ones found in an input value=“” or a <textarea>.

I’ve been unable to make it work. Here’s the basic test that will replace everything.


<?php

$html = 'email@address.com <input type="text" value="email@address.com" /> <textarea>email@address.com</textarea>';

        $html = preg_replace("/([A-Za-z0-9._%-+]+)\\@([A-Za-z0-9._%-]+)\\.([A-Za-z.]{2,4})/", "<script>document.write('\\\\1' + '&#64;' + '\\\\2.\\\\3');</script><noscript>Click here to reveal this email</noscript>", $html);

echo $html;

?>

you may not able to do this in a single step, consider first extracting all the <input — /> tags, then do the email filtering separately for each blocks

I wonder how it can be.
There is no reason to have a text combined with HTML form controls.