|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
pattern to eregi_replace
I am trying to delete a row from a tab delimited text file. The row contains data including an email address. I want to use a pattern that looks for the whole row so I can replace it with a blank row (thereby deleting it from the file). I am using PHP3 and the eregi_replace() function. The pattern that I have tried (which doesn't work) is $pattern="^(\n+)([.]+)?($email+)([.]+)?(\n+)";
I am trying to search for everthing between the returns (the whole row) that also contains a specific email address. Basically, I am trying to delete an entry from a mailing list using the email as a reference. Can someone help me with a pattern that would do this? |
|
#2
|
|||
|
|||
|
PHP 3 ey? Does it have ereg_replace? I'm assuming not, so how about just searching for everything that's *not* the email address, something like this:
^[\$email]?[$email][\$email]?$ Just a rough idea, but if you could post a couple of rows then i could see how they look and forumate a better pattern... |
|
#3
|
|||
|
|||
|
eregi_replace clip with bad pattern
I tested the eregi_replace and found that it actually works, but I have to find a good pattern. Here is what I have...
$email_unsubscribe=trim($email_unsubscribe); $the_file="lists/data.txt"; $open=fopen ($the_file,"r"); $pattern="^(\n+)([.]+)?($email+)([.]+)?(\n+)"; $replace="\n"; if ($open) { $data=file($the_file); $data=implode("",$data); if (eregi($pattern,$data)) { $data=eregi_replace($pattern,$replace,$data); fclose ($open); $open=fopen ($the_file,"w"); if ($open) { fwrite($open,$data); fclose ($open); header("location:unsubscribe_success.php?email=$email_unsu bscribe"); } } else { header("location:unsubscribe_failed.php?email=$email_unsub scribe"); } } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > pattern to eregi_replace |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|