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' + '@' + '\\\\2.\\\\3');</script><noscript>Click here to reveal this email</noscript>", $html);
echo $html;
?>