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

 

[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected],

 

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
https://forums.phpfreaks.com/topic/243923-preg_match-help/
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
https://forums.phpfreaks.com/topic/243923-preg_match-help/#findComment-1252503
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 = "[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]";
$emails = preg_replace('~(?:^|,)[^@]+@(??!(?:,|(yahoo|rocketmail|ymail)\.com)).)+~i','',$emails);

 

Link to comment
https://forums.phpfreaks.com/topic/243923-preg_match-help/#findComment-1253480
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.