Jump to content

preg_match help


devWhiz

Recommended Posts

I need to grab what is in between

 


('Row: 1, Field: 1')"

 

and

 

('Row: 10, Field: 40')

 

also, would it be possible for regex to remove certain emails from a list in this format

 

pmssweet@yahoo.com, cuddles150@msn.com, xxmrsevilxx@msn.com, glentjackson2@yahoo.com, glentjackson2@ymail.com, glentjackson2@rocketmail.com, alexkilledkenny@yahoo.com, wvsilver2002@yahoo.com, raceinvader@yahoo.com, csexiboi001@aol.com,

 

I want to remove all of the aol emails and msn emails and gmail emails and only leave yahoo.com, rocketmail.com and ymail.com, all other emails I want deleted

 

Link to comment
Share on other sites

1. what exactly do you need to grab between the parenthesis?

2. yes you can, using preg_match to weed out the invalid email adresses with a pattern like, however, re-reading your post makes me wonder exactly which emails you want to get rid of?

 

 

Link to comment
Share on other sites

$content = <<<EOF
('Row: 1, Field: 1')"stuff here('Row: 10, Field: 40')
EOF;
preg_match("~\('Row: 1, Field: 1'\)\"\K(??!\('Row: 10, Field: 40'\)).)*~",$content,$match);

 

$emails = "pmssweet@yahoo.com, cuddles150@msn.com, xxmrsevilxx@msn.com, glentjackson2@yahoo.com, glentjackson2@ymail.com, glentjackson2@rocketmail.com, alexkilledkenny@yahoo.com, wvsilver2002@yahoo.com, raceinvader@yahoo.com, csexiboi001@aol.com, test@yahoo.com, blah@blah.com";
$emails = preg_replace('~(?:^|,)[^@]+@(??!(?:,|(yahoo|rocketmail|ymail)\.com)).)+~i','',$emails);

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.