Jump to content

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


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 hotmail_sucks@yahoo.com (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 hotmail_sucks@yahoo.com (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 hotmail_sucks@yahoo.com (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

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.