Re: Regex æøå email validation?
| From: | mike | Date: | Mon, 24 Sep 2007 20:23:42 +0000 |
| Subject: | Re: Regex æøå email validation? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262433@lists.php.net to get a copy of this message | ||
On 9/24/07, Per Jessen <per@computer.org> 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.