[newb] preg_replace for an email string

This is a discussion on [newb] preg_replace for an email string within the PHP Language forums, part of the PHP Programming Forums category; hi, while i'm not new to php, i'm new to pattern matching and am finding it rather difficult .. ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-26-2005
luke
 
Posts: n/a
Default [newb] preg_replace for an email string


hi,

while i'm not new to php, i'm new to pattern matching and am finding it
rather difficult .. i would like to take a string that's an email address,
and change the '@' with '(at)' and any '.'s with '(dot)'. so for instance,
email@nospam.com.au would become email(at)nospam(dot)com(dot)au.

many thanks for any pointers
luke



Reply With Quote
  #2 (permalink)  
Old 04-26-2005
Micha³ Wo¼niak
 
Posts: n/a
Default Re: [newb] preg_replace for an email string

One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable luke's handwriting:

>
> hi,
>
> while i'm not new to php, i'm new to pattern matching and am finding it
> rather difficult .. i would like to take a string that's an email
> address, and change the '@' with '(at)' and any '.'s with '(dot)'. so
> for instance, email@nospam.com.au would become
> email(at)nospam(dot)com(dot)au.
>
> many thanks for any pointers
> luke


Why use preg_replace? It's like firing a cannon on a mosquito. I'd
recommend str_replace - refer to www.php.net for documentation. It will
do exactly what you need.

Cheers
Mike
Reply With Quote
  #3 (permalink)  
Old 04-26-2005
luke
 
Posts: n/a
Default Re: [newb] preg_replace for an email string



"Micha³ Wo¼niak" <mikiwoz_remove_this@yahoo_remove_this.co.uk> wrote in
message news:d4kn37$5q0$1@213-238-73-81.adsl.inetia.pl...
> One quick glance of an experienced eye allowed to understand the blurred
> and almost unreadable luke's handwriting:
>


i like to keep my helpers on their toes.

thanks for the tip.



Reply With Quote
  #4 (permalink)  
Old 04-26-2005
spampop.10.zmalltalker@spamgourmet.com
 
Posts: n/a
Default Re: preg_replace for an email string

preg_replace(array("/@/","/\./"),array("(at)","(dot)"),"first.last@host.domain.t ld");

Have fun!

Marius

Reply With Quote
  #5 (permalink)  
Old 04-27-2005
luke
 
Posts: n/a
Default Re: preg_replace for an email string


ooh. now that's what i was looking for. many thanks marius!




"spampop.10.zmalltalker@spamgourmet.com" <marius.mathiesen@gmail.com> wrote
in message news:1114511956.918311.266300@z14g2000cwz.googlegr oups.com...
>

preg_replace(array("/@/","/\./"),array("(at)","(dot)"),"first.last@host.doma
in.tld");
>
> Have fun!
>
> Marius
>



Reply With Quote
  #6 (permalink)  
Old 04-27-2005
hackajar@gmail.com
 
Posts: n/a
Default Re: preg_replace for an email string

And to get back to the "cannon on a mosquito" claim

$email = "noSPAM@example.org";
$old = array("@", ".");
$new = array("(at)", "(dot)');

str_replace($old, $new, $email);

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:06 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0