Page 1 of 1

Replace all Emails in all php files using Linux sed with php

Posted: Fri Mar 12, 2010 8:36 am
by nagarajuv
Hi All,

I have a problem while replacing all Email Id's in a directory of .php files with some other email id using linux sed function and php system function.Here the code looks like this,
//
$data="find . -name "*.php" | xargs sed -i s/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/nagarajuv@gmail.com/g";
system($data);

//

when I use Email id in place of regular expression it is working fine.Can anyone help me in this


Thanks,
Nagarajuv

Re: Replace all Emails in all php files using Linux sed with php

Posted: Fri Mar 12, 2010 10:41 am
by AbraCadaver
It doesn't match any emails? The regex should match: me@example.com but not: me@mail.example.com. You might try single quotes around the $data string.

Re: Replace all Emails in all php files using Linux sed with php

Posted: Fri Mar 12, 2010 11:26 pm
by nagarajuv
I tried with single quotes but its still giving a problem. Can you please give the regular expression that match all emails in all .php files using linux sed function along with php system function or How can we do this with PHP script.Please help me I am new to this environment.


Thanks for Reply