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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nagarajuv
Forum Newbie
Posts: 6
Joined: Fri Mar 12, 2010 8:14 am
Location: Hyderabad,India
Contact:

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

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

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

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
nagarajuv
Forum Newbie
Posts: 6
Joined: Fri Mar 12, 2010 8:14 am
Location: Hyderabad,India
Contact:

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

Post 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
Post Reply