how to remove email & links ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fred

    how to remove email & links ?

    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


  • Tim Van Wassenhove

    #2
    Re: how to remove email & links ?

    On 2004-01-24, Fred <frederes@free. fr> wrote:[color=blue]
    > 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 ?[/color]

    And i would like you to lookup what the difference between multi-posting
    and crossposting is.


    --

    Comment

    • Chung Leong

      #3
      Re: how to remove email &amp; links ?

      $patterns = array('<[\w.]+@[\w.]+>', '<\w{3,6}:(?:(? ://)|(?:\\\\))[^\s]+>');
      $matches = array('******** **', '**********');
      echo preg_replace($p atterns, $matches, "hello, write to zozo@zozo.com and
      look http://toto.zozo.com") ;

      Use preg_replace_ca llback() if the length of the replacement has to match
      the length of the original.

      Uzytkownik "Fred" <frederes@free. fr> napisal w wiadomosci
      news:buttqr$oga $1@news-reader5.wanadoo .fr...[color=blue]
      > 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
      >
      >[/color]


      Comment

      Working...