Re: [PHP] Regex for email validation
tedd wrote: However, it's one thing to have a keyboard designed for a specific language and another to be able to enter code-points that aren't associated with any specific language (i.e., Dingbats and Math Symbols). Ah yes, that's true. How about an APL2 keyboard then? :-) For example, note that Rx,com is not associated with any language, which is the same as many of my other domains, as you can see some here: http://symboldomains.com/symbol-domains-for-sale.html Of course, some of those are closely associated with the greek language/alphabet, but I take your point. I think the problem is mostly on the domain owner side though - if you register a domain for publishing something or other, but most of your intended audience cannot enter it in an easy, straight-forward way, you've only shot yourself in the foot, haven't you? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
tedd wrote: But as it is now, it's not so much IF the domain name is easy to type in or not, but rather does the Rx.com show up in the URL once you get there? And it does for most browsers other than IE. You can get to the site very easily, try typing: http://rx-2.com That wasn't hard, now was it? What should have happened here, Tedd? I just got the message you have the wrong Browser - I'm using Firefox, I thought that was perfectly capable of using IDNs. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Per Jessen wrote: tedd wrote: But as it is now, it's not so much IF the domain name is easy to type in or not, but rather does the Rx.com show up in the URL once you get there? And it does for most browsers other than IE. You can get to the site very easily, try typing: http://rx-2.com That wasn't hard, now was it? What should have happened here, Tedd? I just got the message you have the wrong Browser - I'm using Firefox, I thought that was perfectly capable of using IDNs. Interesting - I copy-pasted the Rx symbol (from your webpage) into FF and appended .com - and FF converted the URL symbol to xn--u2g.com. I guess FF only works with a limited subset of the many possible special characters. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
tedd wrote: The WG did solve this issue and came up with a way to do that -- the current algorithm is called PUNYCODE which allows Unicode code-points to appear in a domain name. I know this to be true because I have several domains that lie outside the standard ASCII AND they are real domains that have real web sites. That was never in dispute, Tedd - IDNs are well known, certainly around here. If you have a browser (like Safari) that is capable of showing the URL in it's native charset, then you will see the Rx.com in the url. If not, then you'll see xn--u2g.com. I think most browsers will work with IDNs today, possibly with the exception of MSIE (?) Now, email can be sent from that domain, but I have not found an application that will send nor receive it. The software has simply not caught up with the technology. Which is weird, to say the least. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Kevin Waterson wrote: There is no silver bullet regex to validate all RFC compliant email address. Many have tried, but they all fail at some point. The best you can do is cater to most _sane_ addresses. Exactly - the regex is a quick/cheap sanity check, nothing more. To go all the way, you could try doing an SMTP VRFY against the MX for the domain, but it's really taking it a bit too far. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
That Rx.com domain name is really great stuff, but how do you expect the average user to type it in? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Yeti wrote: That Rx.com domain name is really great stuff, but how do you expect the average user to type it in? Sorry, I don't understand the problem. The average user will obviously have a suitable keyboard, such as this for instance: http://en.wikipedia.org/wiki/Image:KB_Swiss.svg /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
At 9:29 AM +0200 8/28/08, Yeti wrote: That Rx.com domain name is really great stuff, but how do you expect the average user to type it in? Of course the problem has always been how can the user enter these types of characters from their keyboard. But, that's pretty simply with a Mac and as the rest of the world continues to log-on to the Internet (in record numbers in their own languages) I am sure that the problem of how to type in non-ASCII characters will become more of an issue and the solution will solve my problem as well. But as it is now, it's not so much IF the domain name is easy to type in or not, but rather does the Rx.com show up in the URL once you get there? And it does for most browsers other than IE. You can get to the site very easily, try typing: http://rx-2.com That wasn't hard, now was it? The same could be done for: http://www.jnj.com or any other Pharmaceutical Company -- or at least that's what I'm selling. Now, will some bright young savvy pharmaceutical executive recognize the opportunity or will this idea continue to float around until it becomes obvious to the brain-dead -- your guess is as good as mine. But, the day is coming. I just hope that I don't have to will my symbol domains to my son or grandson to finally have them pay off. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
At 9:34 AM +0200 8/28/08, Per Jessen wrote: Yeti wrote: That Rx.com domain name is really great stuff, but how do you expect the average user to type it in? Sorry, I don't understand the problem. The average user will obviously have a suitable keyboard, such as this for instance: http://en.wikipedia.org/wiki/Image:KB_Swiss.svg /Per Jessen, Zürich I hope you're right. However, it's one thing to have a keyboard designed for a specific language and another to be able to enter code-points that aren't associated with any specific language (i.e., Dingbats and Math Symbols). For example, note that Rx,com is not associated with any language, which is the same as many of my other domains, as you can see some here: http://symboldomains.com/symbol-domains-for-sale.html I bought most of these eight years ago hoping that someone would see things the way I do. But despite all my time, effort, and cost -- the only thing I have received is being called a goofy nitwit -- which I probably am -- but I would like to think of myself as an entertaining nitwit. :-) I have grandiose plans, but unfortunately I'm the only one who see's them. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
On 8/27/08, VamVan [EMAIL PROTECTED] wrote: Hello Guys, Does any have a regex for email validation? I need to allow only period and underscore in the local part , we would need a @ and .com or watever for domain. php should have a good check built-in. see http://www.php.net/manual/en/function.filter-var.php if(!filter_var($var, FILTER_VALIDATE_EMAIL)) { echo invalid email; } some people also go the extra mile and verify the MX record is valid, or lookup the MX record and even validate the user exists by querying the mail server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
VamVan wrote: Hello Guys, Does any have a regex for email validation? I need to allow only period and underscore in the local part , we would need a @ and .com or watever for domain. Option 1: /[EMAIL PROTECTED]/ This is probably what you meant: /[EMAIL PROTECTED]/ /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
That's a very handy extension. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com mike wrote: php should have a good check built-in. see http://www.php.net/manual/en/function.filter-var.php if(!filter_var($var, FILTER_VALIDATE_EMAIL)) { echo invalid email; } some people also go the extra mile and verify the MX record is valid, or lookup the MX record and even validate the user exists by querying the mail server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Does any have a regex for email validation? I need to allow only period and underscore in the local part , we would need a @ and .com or watever for domain. You could: 1. Take the isValidInetAddress() method out of the PEAR Mail_RFC822 class and use that. 2. Use the filter extension which I understand is now part of PHP (5.2.x+) This would the preferable option. -- Richard Heyes HTML5 Graphing: http://www.phpguru.org/RGraph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
At 9:31 AM +0200 8/27/08, Per Jessen wrote: VamVan wrote: Hello Guys, Does any have a regex for email validation? I need to allow only period and underscore in the local part , we would need a @ and .com or watever for domain. Option 1: /[EMAIL PROTECTED]/ This is probably what you meant: /[EMAIL PROTECTED]/ /Per Jessen, Zürich Which is probably what you meant: eregi([EMAIL PROTECTED],6}$, $email) Email comes in different TLD flavors. But, even that still doesn't cover all the possible and legal Unicode code-points that can exist on both sides of the @ of an email address. For example: [EMAIL PROTECTED] is a legal and working email address. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
?php # this one worked fine for me, but it does not cover the full RFC like: name [EMAIL PROTECTED] OR name [EMAIL PROTECTED] $regex = ^[a-z0-9,!#\$%'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%'\*\+/=\?\^_`\{\|}~-]+)[EMAIL PROTECTED](\.[a-z0-9-]+)*\.([a-z]{2,})$; if (eregi($regex, $email)) { // do something } # Beware that the filter functions only work under PHP5+. If your PHP supports them they should be the preferred choice ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
tedd wrote: Option 1: /[EMAIL PROTECTED]/ This is probably what you meant: /[EMAIL PROTECTED]/ /Per Jessen, Zürich Which is probably what you meant: eregi([EMAIL PROTECTED],6}$, $email) Email comes in different TLD flavors. Well, I left that for the OP to figure out. Still, your regex is worse - a domain name cannot contain '%'. The only valid characters for a domain name are letters, numbers and a hyphen. Also, maximum length for a domain name is 64 characters, which could/should be checked too. But, even that still doesn't cover all the possible and legal Unicode code-points that can exist on both sides of the @ of an email address. No, they can't. There are no 8-bit characters allowed in an email-address. Check out RFC2821. [EMAIL PROTECTED] is a legal and working email address. If that reads tedd(at)space.com, it might be valid on your system, but not in public. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Yeti wrote: ?php # this one worked fine for me, but it does not cover the full RFC like: name [EMAIL PROTECTED] OR name [EMAIL PROTECTED] $regex = ^[a-z0-9,!#\$%'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%'\*\+/=\ \^_`\{\|}~-]+)[EMAIL PROTECTED](\.[a-z0-9-]+)*\.([a-z]{2,})$; For the domain part, I would check against @([a-z0-9-]+\.)+[a-z0-9-]+ and then do a lookup for an A record. There are still some patterns that will fit the above, without being valid domain-names. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
mike a écrit : php should have a good check built-in. see http://www.php.net/manual/en/function.filter-var.php Argh ! Howmany times it is in ? I spent so many time to write a regex that belongs the RFC822 :-/ Because all the regex in answer here was false. They don't allow email like Mickael Doodoo@lupusmic.com nor [EMAIL PROTECTED] ; and they are valuable email addresses. Without the fact that a top level domain isn't always between two and three characters (think about .museum). -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Lupus Michaelis wrote: Argh ! Howmany times it is in ? I spent so many time to write a regex that belongs the RFC822 :-/ Because all the regex in answer here was false. They don't allow email like Mickael Doodoo@lupusmic.com nor That format is about as dead as the dinosaurs. I know it IS a valid format, but ... /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
At 6:30 PM +0200 8/27/08, Per Jessen wrote: Well, I left that for the OP to figure out. Still, your regex is worse - a domain name cannot contain '%'. The only valid characters for a domain name are letters, numbers and a hyphen. Also, maximum length for a domain name is 64 characters, which could/should be checked too. Well, I stole that regex anyway -- I agree that % should have not been there. No, they can't. There are no 8-bit characters allowed in an email-address. Check out RFC2821. You can throw all the facts and documentation you want at me, but the left side of the @ has always been open to anything you want. The right side of the @ has had to deal with 7-bit limitation (the DNS problem). But, considering the work that the IDNS has done, (circa 2000) we can use Unicode characters on both sides of the @. However, the software (browsers and email apps) may/may-not be able to deal with it, as shown by my recent example of: [EMAIL PROTECTED] is a legal and working email address. If that reads tedd(at)space.com, it might be valid on your system, but not in public. The email address is perfectly valid, and works, but our definition of public is apparently different. I claim if it's valid on any system, then it's public. I don't hold to the notion that if M$ doesn't recognize it then it isn't public. M$ has always had it's collective head up it's vested interest butt anyway. For demonstration Safari has absolutely no problems dealing with IDNS, whereas all IE's do. To prove my point, if you have Safari, try entering option v into the browser URL box and hit return. You don't have to enter anything else (i.e., no http://, www, or dot com). What will happen is that you will be automagically transported to one of my sites where the url is square-root dot com. However if you're dealing with one of the leading also-ran IE browsers, then you'll see the PUNYCODE equivalent, which was never intended to be seen by end users anyway. Just another example of how M$ always has a better idea. So, regardless of the documentation, which may be outdated, I know that Unicode characters can be used in IDNS and thus on both sides of the @, but it's the software that needs to catch up to the technology. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
At 7:55 PM +0200 8/27/08, Lupus Michaelis wrote: mike a écrit : php should have a good check built-in. see http://www.php.net/manual/en/function.filter-var.php Argh ! Howmany times it is in ? I spent so many time to write a regex that belongs the RFC822 :-/ Because all the regex in answer here was false. They don't allow email like Mickael Doodoo@lupusmic.com nor [EMAIL PROTECTED] ; and they are valuable email addresses. Without the fact that a top level domain isn't always between two and three characters (think about .museum). Or TLD's like: http://tedd.mobi/ Things are a changing fast. Just wait until you start designing stuff for cell phones. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
tedd wrote: No, they can't. There are no 8-bit characters allowed in an email-address. Check out RFC2821. You can throw all the facts and documentation you want at me, but the left side of the @ has always been open to anything you want. Except anything 8-bit, yes. Seriously, read RFC2821 and maybe -2822 The right side of the @ has had to deal with 7-bit limitation (the DNS problem). But, considering the work that the IDNS has done, (circa 2000) we can use Unicode characters on both sides of the @. No, you cannot. Certainly not on the left side, and only on the right side if you assume visual representation = email-address. Why don't you send me an email at this address: [EMAIL PROTECTED] (that's an a with accent grave like in your domain further down). However, the software (browsers and email apps) may/may-not be able to deal with it, as shown by my recent example of: [EMAIL PROTECTED] is a legal and working email address. If that reads tedd(at)space.com, it might be valid on your system, but not in public. The email address is perfectly valid, and works, but our definition of public is apparently different. Sorry, I didn't see the a with the accent grave. Still, try using that address in Thunderbird, and you'll see that it doesn't work. The correct email-address (which is what we're talking about) for '[EMAIL PROTECTED]' is [EMAIL PROTECTED], which an email-system like sendmail/exim/postfix/etc will understand (whereas it will choke on '[EMAIL PROTECTED]'. So, regardless of the documentation, which may be outdated, I know that Unicode characters can be used in IDNS and thus on both sides of the @, You're wrong - IDNs only apply to the right side of the @. (check out what the 'D' means). Go on, send me that email to '[EMAIL PROTECTED]' ... for what it's worth, I can't even define an account like that, so my mailserver might well reject it. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Per Jessen a écrit : That format is about as dead as the dinosaurs. Why ? -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Lupus Michaelis wrote: Per Jessen a écrit : That format is about as dead as the dinosaurs. Why ? I don't know, but I suspect due to lack of support in popular mailers and mail-servers. Also, the use of quotes does make it cumbersome to work with, both as a user and as a mailserver admin. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Per Jessen a écrit : I don't know, but I suspect due to lack of support in popular mailers and mail-servers. Also, the use of quotes does make it cumbersome to work with, both as a user and as a mailserver admin. I had to write some pieace of code that can handle toto toto@ndd five years ago, it was Lotus Mail habits of the end users ;) -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
At 8:35 PM +0200 8/27/08, Per Jessen wrote: Go on, send me that email to '[EMAIL PROTECTED]' ... for what it's worth, I can't even define an account like that, so my mailserver might well reject it. Yes, you are right. I was thinking of something else, namely that the LHS of the email address is case-sensitive -- this was something that was discussed about five years ago on the IDNS list, of which I attended. Considering that the list was created to solve the IDNS problem, I mistakenly remembered them were discussing IDNS problems, but instead they were discussing case-sensitivity. Sorry to add to the confusion. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
At 8:35 PM +0200 8/27/08, Per Jessen wrote: So, regardless of the documentation, which may be outdated, I know that Unicode characters can be used in IDNS and thus on both sides of the @, You're wrong - IDNs only apply to the right side of the @. (check out what the 'D' means). The D in IDNS is Internationalized Domain Names -- note what the 'I' stands for. I was wrong to say that Unicode code points can be used on the LHS of the @ but domain names contain Unicode code points (in fact, that's all they contain) and thus these code points can appear on the RHS of email. For example, one *can* use other than ASCII characters in a domain name -- that's what the IDNS WG was for solving. The WG did solve this issue and came up with a way to do that -- the current algorithm is called PUNYCODE which allows Unicode code-points to appear in a domain name. I know this to be true because I have several domains that lie outside the standard ASCII AND they are real domains that have real web sites. For example: http://xn--u2g.com If you have a browser (like Safari) that is capable of showing the URL in it's native charset, then you will see the Rx.com in the url. If not, then you'll see xn--u2g.com. Now, email can be sent from that domain, but I have not found an application that will send nor receive it. The software has simply not caught up with the technology. One thing for sure, as the rest of the world logs on, more and more people will demand that their applications will implement the capabilities of the current IDNS. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
This one time, at band camp, Yeti [EMAIL PROTECTED] wrote: ?php # this one worked fine for me, but it does not cover the full RFC like: name [EMAIL PROTECTED] OR name [EMAIL PROTECTED] $regex = ^[a-z0-9,!#\$%'\*\+/=\?\^_`\{\|}~-]+(\.[a-z0-9,!#\$%'\*\+/=\?\^_`\{\|}~-]+)[EMAIL PROTECTED](\.[a-z0-9-]+)*\.([a-z]{2,})$; if (eregi($regex, $email)) { // do something } # Beware that the filter functions only work under PHP5+. If your PHP supports them they should be the preferred choice ? There is no silver bullet regex to validate all RFC compliant email address. Many have tried, but they all fail at some point. The best you can do is cater to most _sane_ addresses. And when the domain name space is opened up, well, you will back to strpos() and @ Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex for email validation
Honestly, I'd stick to using php's filter extension. It -should- be the best one out there. If it is not processing something it should, then it's a bug - submit it so all of us benefit :) I am tired of trying to find regexps and all that every time, I put my stock into PHP's core when I can. On 8/27/08, Lupus Michaelis [EMAIL PROTECTED] wrote: mike a écrit : php should have a good check built-in. see http://www.php.net/manual/en/function.filter-var.php Argh ! Howmany times it is in ? I spent so many time to write a regex that belongs the RFC822 :-/ Because all the regex in answer here was false. They don't allow email like Mickael Doodoo@lupusmic.com nor [EMAIL PROTECTED] ; and they are valuable email addresses. Without the fact that a top level domain isn't always between two and three characters (think about .museum). -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex æøå email validation?
Søren Neigaard wrote: It works fine, but my friend strangely enough has users with special danish letters (æøåÆØÅ) in their email address, and that it does not accept. Hej Søren I just realised - you can't have those characters in the email address. You may have them in the name part, but not in the address part. If you have them in the domain, you need to convert them to punycode before you validate. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex æøå email validation?
Søren Neigaard wrote: Hi guys Im helping a friend with hes internet site, and I have found this regex email validation regex on the internet: var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a- z]{2,6}(?:\.[a-z]{2})?)$/i; if(!filter.test(email)) { return false; } It works fine, but my friend strangely enough has users with special danish letters (æøåÆØÅ) in their email address, and that it does not accept. Regex is black magic to me, I have tried to modify it in different ways, but with no luck. I know its not PHP specific (its JavaScript), but maybe one of you can help me anyways? Hej Søren to get it to work, you need to be in the Danish locale, otherwise æøå won't be recognised as being word-characters. In javascript, I'm not sure, but maybe you have to use UTF-8? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regex æøå email validation?
On 9/24/07, Per Jessen [EMAIL PROTECTED] wrote: Hi guys Im helping a friend with hes internet site, and I have found this regex email validation regex on the internet: var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a- z]{2,6}(?:\.[a-z]{2})?)$/i; if(!filter.test(email)) { return false; } It works fine, but my friend strangely enough has users with special danish letters (æøåÆØÅ) in their email address, and that it does not accept. Regex is black magic to me, I have tried to modify it in different ways, but with no luck. I know its not PHP specific (its JavaScript), but maybe one of you can help me anyways? have you looked into http://php.net/filter functions? not sure if those are locale-friendly or not. if(filter_var($foo, FILTER_VALIDATE_EMAIL)) {} has worked for me. i don't use any extended characters though. but changing your locale in PHP might allow it to work.