Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex with emails 1

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
0
0
GB
Hi,

I'm trying to do a regex to match email accounts from a specific domain.

So say, I'm trying to match all people that use my registration form using a Hotmail account.

This is the regex expression I have right now. Doesn't seem to match any hotmail accounts as valid though.

var emailFilter = new RegExp("^\w+@hotmail\.com$");

I've also tried

var emailFilter=/^\w+@/hotmail/\./com$//;

But this doesn't even initiate my javascript alert!

Anyone have any tips or could point out where I've gone wrong?
Thanks.

Maldini
 
can you clarify? do you just want to see if "@hotmail.com" is in the email string?

var email = "foobar@hotmail.com";
var re = /@hotmail\.com/;
alert( re.test(email) );


=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Yup, basically thats what I'm trying to do.
Thanks, your suggestion provided the solution, in the end I used :
var FilterIt = /\w+@hotmail\.com/;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top