View Full Version : Parsing for emails
Can anyone whip up a quick hack which parses the contents of a message for an email address (probably looking for the @ sign) and automatically adds the email tags to it, similarly to automatically parsing for URL's.
I believe that$messagetext = eregi_replace("([_a-z0-9-]+(\.[_a-z0-9-]+)*)@([a-z0-9-]+(\.[a-z0-9-]+)*)","<A HREF=\"mailto:\\1@\\3\">\\1@\\3</A>",$messagetext);will work. This one does not do any validation; it just looks for something@something. You might also try throwing some weird addresses at it to see if the \\1@\\3 part remains valid for all forms of "." separated names.
That seems to have worked great. It only works if HTML is on in a forum, otherwise it prints the tags.
Thanks!
You can better do it this way to keep up the consistency with Vb, in this case it doesn't matter if html is turned on or off:
$messagetext = eregi_replace("([_a-z0-9-]+(\.[_a-z0-9-]+)*)@([a-z0-9-]+(\.[a-z0-9-]+)*)","\\1@\\3",$messagetext);
untested but I think it'll work
NB: Replace _email with email (twice)
[Edited by Mas*Mind on 09-07-2000 at 01:09 PM]
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.