Okay if you just want to do a REGEX something like

ereg("([_a-zA-Z\-]+|\*)\@[\.a-zA-Z\-]+\.com",$variable);

should work, but test it. I'm not 100% the wildcard part will work.


If you want to make sure the domain is valid, well that's much more fun ;)...

function validateAddr($addr)
{
        /* UNTESTED- whipped together in about 2 mins, so test before use */
        if ( !ereg("[_a-zA-Z\-]+\@[\.a-zA-Z\-]+\.com",$addr) )
        {
                exit("eMail address format invalid.");
        }
        else
        {
                $host = explode("@",$addr);
                $host = $host[1];
                if ( !getmxrr($host, $array) )
                {
                        exit("Invalid eMail address- domain $host does not exist...");
                }
        }
}

I hope your eMail client doesn't wrap that. If it does eMail me and I'll send 
you a text file. Meanwhile, it is untested so test before use.

If you want to get really in-depth, you could try to send $host:25 EXPN or 
VRFY requests, but they SHOULDN'T respond to those so I wouldn't do that if I 
were you.



On Wednesday 24 April 2002 09:29 am, you wrote:
> Hey Evan,
>
> I need it so that I would accept any valid domain, so domain.com,
> or domain.net, or domain.org, domain.biz, etc. Also I need it so
> that before the @ sign or after the at sign it can have a '*' for
> wildcard.
>
> Could you help me with this?
>
> Devin
>
>
> -----Original Message-----
> From: Evan Nemerson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 23, 2002 4:38 PM
> To: Devin Atencio; [EMAIL PROTECTED]
> Subject: Re: [PHP] Regular Expressions
>
>
> Uhhh... something like
>
> ereg("[_a-zA-Z\-]+\@[\.a-zA-Z\-]+\.com",$variable);
>
> SHOULD work... If you want to make sure they're @domain.com instead of any
> domain, try...
>
> ereg("[_a-zA-Z\-]+\@[\.a-zA-Z\-]+domain\.com",$variable);
>
> if you want to validate e-mail address formats, there is (if memory serves)
> a
> discussion in the comments on php.net/eregi of how to do this best.
>
> > I need to check a variable to see if the format fits one
> > of the following:
> >
> > [EMAIL PROTECTED]
> >  or
> > *@domain.com
> >  or
> > *@*.domain.com
> >
> > How can I do this with regex? Any help would be greatly
> > appreciated.
> >
> > Devin Atencio

-- 
Nobody realizes that some people expend tremendous energy merely to be 
normal.

Albert Casmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to