我有一个包含电子邮件更换损坏的电子邮件地址,使用PHP
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
@domain.com
[email protected]
[email protected]
我需要从列表中删除@ domain.com列表的文件file.txt的。我使用此代码:
file_put_contents('file.txt',
str_replace("@domain.com","",file_get_contents('file.txt')));
但是,这也将删除[email protected]
@domain.com
,使其成为一个不正确的列表。
我该怎么做?
感谢您的开头! ereg_replace也不错? – gr68 2014-12-05 14:37:53
您可以使用该方法。但似乎这种方法已被废弃(如http://php.net/manual/en/function.ereg-replace.php中所述)。所以最好使用preg_replace(或preg_replace_all) – 2014-12-05 14:39:25
你必须逃避点,因为它意味着任何字符。 – Toto 2014-12-05 15:12:56