Gossamer Forum
Home : General : Perl Programming :

Trying to Convert E-mail.......

Quote Reply
Trying to Convert E-mail.......
$text = qq|

This is text and it contains a couple of e-mail addresses, like FOO@xyz.com and bar@abc.com what If I want to search for these addresses in the text and perform search and replace function on those.

|;

I want to perform search and replace on the above $text (only for E-mail addresses (\s.*?@.*?\s) ). Once the email addresses are captured, converted to all lower case. I want to do simple replacement of characters like; e.g. f replaced by Q , o replaced M , c by L, m by Tetc etc..

so that the above string would become;

"This is text and it contains a couple of e-mail addresses, like QMM@xyz.LMT and bar@abc.LMT what If I want to search for these addresses in the text and perform search and replace function on those"

Simply want to encrypt the mail addresses but in the way as specified above.

Any help with REGEX?

Thanks,

Sara.
Quote Reply
Re: [samsara] Trying to Convert E-mail....... In reply to
Code:
my (@emails) = $string =~ /(\S+@\S+\.\S+)/g;
for (@emails) {
tr/foc/QML/;
}

Something like that may work.

Last edited by:

Recall: Nov 21, 2003, 10:35 AM