View Single Post

  #2 (permalink)  
Old 01-25-2004
Bryan Chan
 
Posts: n/a
Default Re: how to replace emails & links in a string ?

$sText = "hello, write to zozo@zozo.com and look http://toto.zozo.com !!";
$sMask = preg_replace('/((http:\\/\\/)?[-_a-z0-9]+([@\\.][-_a-z0-9]+)+)/ie',
'str_repeat("*", strLen("\\1"))', $sText);
print $sMask;

Bryan


"Fred" <frederes@free.fr> wrote in message
news:buttsb$ol7$1@news-reader5.wanadoo.fr...
> hi,
>
> i want to remove emails & links strings in a string, replacing them with
> **** for instance.
> I don't know how to do with regexp...could you help me ?
>
> ex :
> source text : "hello, write to zozo@zozo.com and look http://toto.zozo.com
> !!"
> i wantr : "hello, write to ************* and look ******************** !!"
>
> thanks for any help !
>
> fred
>
>



Reply With Quote