Jump to content

[SOLVED] getting only HOTMAIL users' emails and NOT Yahoo?


samoi

Recommended Posts

Hello guys!

 

I have users in my db, but I need to bring up only the hotmail users only and not any other users! from their emails!

 

So I went with this but I'm stuck !:

$SQL = 0 ; // the query to pull up the ALL emails!
while($row = mysql_fetch_row($SQL)) {//there are emails
$emails = preg_replace('/([\w-\.]+)@(hotmail).([a-zA-Z]{2,4}\.[a-zA-Z]{2,4}|[a-zA-Z]{2,4})/','\1@\2\3',$row[0]);

echo $emails;
}

 

 

 

BTW, I only know how to deal with preg_replace!

I have no idea about the complicated preg_match_all() func!

 

all of the preg_xxxx functions use the same pcre regex engine.  If anything, preg_replace is the more complicated one, as it allows you to eval the replacement.

The OP didn't specify they wanted Hotmail.com e-mail addresses, they specified Hotmail addresses (which I assume would include .co.uk and any other variants, especially looking at the OPs Regex). Obviously you could use SELECT * FROM TABLE WHERE `email` LIKE '%hotmail%', but this would match an email address of [email protected] (prepare to be found by a spambot crawler if you own that address), which I assume is not wanted. Regex certainly seems the way forward.

The OP didn't specify they wanted Hotmail.com e-mail addresses, they specified Hotmail addresses (which I assume would include .co.uk and any other variants, especially looking at the OPs Regex). Obviously you could use SELECT * FROM TABLE WHERE `email` LIKE '%hotmail%', but this would match an email address of [email protected] (prepare to be found by a spambot crawler if you own that address), which I assume is not wanted. Regex certainly seems the way forward.

 

RIGHT ON :P

 

SELECT * FROM table WHERE email REGEXP '[^@]+?@hotmail\.[a-z.]{2,5}'

The OP didn't specify they wanted Hotmail.com e-mail addresses, they specified Hotmail addresses (which I assume would include .co.uk and any other variants, especially looking at the OPs Regex). Obviously you could use SELECT * FROM TABLE WHERE `email` LIKE '%hotmail%', but this would match an email address of [email protected] (prepare to be found by a spambot crawler if you own that address), which I assume is not wanted. Regex certainly seems the way forward.

 

RIGHT ON :P

 

SELECT * FROM table WHERE email REGEXP '[^@]+?@hotmail\.[a-z.]{2,5}'

 

That returns

 

ERROR 1139 (42000): Got error 'repetition-operator operand invalid' from regexp

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.