General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 23rd, 2002, 01:26 AM
chiboy chiboy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 4 chiboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old July 23rd, 2002, 08:19 AM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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...

Reply With Quote
  #3  
Old July 23rd, 2002, 08:40 AM
chiboy chiboy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 4 chiboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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");
}
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > pattern to eregi_replace


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway