If I have a text of string like this:

$stuff = "Hi my name is Phil, my email is [EMAIL PROTECTED] and you can find me at 
http://www.xx.yy?[EMAIL PROTECTED]";;

What I want to do is to "validate" all patterns resembling an email address EXCEPT 
those found within the query string of a URL.  I would want to to urlencode(\\1) 
somehow onto the email address pattern found within the query string of the URL to 
ensure that it is not "validated" like any other email address (validate means to 
convert [EMAIL PROTECTED] to <a href=mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]</a>).

Can anyone figure this out for me? I tried using pattern matching and eval() but the 
results were completely wrong:

function VALIDATE_URL($stuff) {
   $stuff = preg_replace('/[\n\r]/', '<br>', $stuff);
   $stuff = preg_replace('/\.\./', ' . .', $stuff);
   // URL ESCAPE ALL EMAIL ADDRESSES FOUND WITHIN QUERY STRINGS TO ENSURE PROPER 
VALIDATION
   // IF USING VALIDATE_EMAIL
   $stuff = 
preg_replace('/([\?&][a-zA-Z0-9]+=)([a-zA-Z0-9_\-\.]+@([a-zA-Z0-9_\-]+\.)+[a-zA-Z0-9_\-]+)/',
 '\\1' . '<? $stuff = urlencode("\\2"); echo $stuff; ?>', $stuff);
   $stuff = eval('?>' . $stuff);
   $stuff = 
preg_replace('/(http[s]?:\/\/([a-zA-Z0-9_\-]+\.)+(\/[a-zA-Z0-9_\-\.\~\^,%\+]+)*[^<\(\)>
 ]+)/', '<a href=\\1 target=_new>\\1</a>', $stuff);
   return preg_replace('/ \. \./', '..', $stuff);
  }

Thanx
Phil

Reply via email to