On Tue, 19 Mar 2002, Pekka Saarinen wrote:
> I need to search text for @ and replace the mail address around it (i.e. 
> text between previous and following spaces) so that if I have text
> Foobar foobar [EMAIL PROTECTED] foobar foobar.
> It'll convert it to
> Foobar foobar <a href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a> foobar foobar.

(warning: untested)

$newstr = preg_replace('/\b(\S+@\S+)\b/',
   '<a href="mailto:\1";>\1</a>', $oldstr);

Take the time to learn Perl-style regular expressions. You can practically 
write Photoshop with them.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to