Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
Re: [PHP] email validation string.
Old
  (#11)
Myron Turner
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

Nuno Oliveira wrote:
>>
>> 1. Why did you remove the backslash? (the original was correct)
>>

> I have a regular expression tester plugin in firefox and it validates Ok
> with the expression he provided.
>
> If I add the second (original) backslash it won't validate emails anymore.
>
> Also, from my little knowledge of Red.Exp. the backslash will escape
> special chars.
> In this case the backslash will escape the dot to match only a dot and
> not all chars...
>
> This my way of seing it...

Either of the following will work as you want it, including testing for
the backslash:

"/[\w\/]{6,}/"
or
("/[\w\\\x2f]{6,}/"

The first is the preferred. The backslash has to be escaped; otherwise
it escapes the character that follows it.

--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

RE: [PHP] email validation string.
Old
  (#12)
tedd
Guest
 
Posts: n/a
Default RE: [PHP] email validation string. - 05-14-2007, 03:35 AM

At 5:54 PM +0200 1/19/07, WeberSites LTD wrote:
>Top Ajax :
>I meant that at the top of WeberDev.com there is an Ajax search box that you
>can use
>to search for "email validation" and see many related code examples to
>choose from.
>
>berber


berber:

Your original post was clear enough for me to understand. Probably
something else going on.

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#13)
Roman Neuhauser
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

# EMAIL REMOVED / 2007-01-20 08:53:32 -0500:
> I picked this up in my travels.
>
> function validate_email($email)
> {
>
> // Create the syntactical validation regular expression
> $regexp =
> "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";


One of my email addresses is
neuhauser+pgsql-general#EMAIL REMOVED.

Also, "[" ip-address "]" is a valid right hand side of an email address,
e. g.:

root@[127.0.0.1]

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#14)
tedd
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

At 3:04 PM +0000 1/20/07, Roman Neuhauser wrote:
># EMAIL REMOVED / 2007-01-20 08:53:32 -0500:
>> I picked this up in my travels.
>>
>> function validate_email($email)
>> {
>>
>> // Create the syntactical validation regular expression
>> $regexp =
>> "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";

>
>One of my email addresses is
>neuhauser+pgsql-general#EMAIL REMOVED.
>


Thanks, I'll add that to my kill list.

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#15)
tedd
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

On Thu, Jan 18, 2007 at 01:40:36PM -0700, Don wrote:
> I'm trying to get this line to validate an email address from a form and it
> isn't working.
>
> if (ereg("^.+@.+\..+$",$submittedEmail))
>


> The book I'm referencing has this line
>
> if (ereg("^.+@.+\\..+$",$submittedEmail))
>
> Anyway.. I welcome any advice as long as it doesn't morph into a political
> debate on ADA standards and poverty in Africa. :-)
>
> Thanks
>
> Don



Don:

I picked this up in my travels.

function validate_email($email)
{

// Create the syntactical validation regular expression
$regexp =
"^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";

// Presume that the email is invalid
$valid = 0;

// Validate the syntax
if (eregi($regexp, $email))
{
list($username,$domaintld) = split("@",$email);
// Validate the domain
if (getmxrr($domaintld,$mxrecords))
$valid = 1;
} else {
$valid = 0;
}

return $valid;

}

$email = "johnny-EMAIL REMOVED";

if (validate_email($email))
echo "Email is valid!";
else
echo "Email is invalid!";

hth's

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#16)
Roman Neuhauser
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

# EMAIL REMOVED / 2007-01-20 09:22:00 -0500:
> At 3:04 PM +0000 1/20/07, Roman Neuhauser wrote:
> >One of my email addresses is
> >neuhauser+pgsql-general#EMAIL REMOVED.

>
> Thanks, I'll add that to my kill list.


Vietnam vet... Old habits don't go away easily huh?

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: [PHP] email validation string.
Old
  (#17)
tedd
Guest
 
Posts: n/a
Default Re: [PHP] email validation string. - 05-14-2007, 03:35 AM

At 3:47 PM +0000 1/20/07, Roman Neuhauser wrote:
># EMAIL REMOVED / 2007-01-20 09:22:00 -0500:
>> At 3:04 PM +0000 1/20/07, Roman Neuhauser wrote:
>> >One of my email addresses is
>> >neuhauser+pgsql-general#EMAIL REMOVED.

>>
>> Thanks, I'll add that to my kill list.

>
>Vietnam vet... Old habits don't go away easily huh?


I didn't think of it that way, but that's a thought. Let's hope that
you never run into a Vietnam vet who thinks that way (they do exist).
As for me, I figure that you've never had any adversity to confront,
so you just don't know any better -- however, I'm sure life
experience and maturity will help you understand. Good luck with that.

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top