Re: [PHP-DB] form validation question - regex not working
be sufficient preg_match(/^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)*@([a-zA-Z\d-]+\.)+([a-zA-Z]{2,4 })$/, $useremail) Oh, what i also have to say the ereg-funktions are to old you schould use the new php4 funktions preg_match() preg_replace() preg_... greet Martin - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 22, 2002 5:06 AM Subject: Re: [PHP-DB] form validation question - regex not working On Thursday 22 August 2002 04:01, [EMAIL PROTECTED] wrote: Got it figured out, and foreign address do work now - if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-])+\.([A-Za-z])+\.([a-z])*$, $useremail)) What do you mean by 'foreign' addresses? The above will still fail for: [EMAIL PROTECTED] -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Dungeons and Dragons is just a lot of Saxon Violence. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] form validation question - regex not working
I hope this isn't too far off topic - I have a regex for validating email addresses - if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-])+\. ([A-Za-z]{2,3})+$, $useremail)) Notice the {2,3} which is supposed to limit the last part to 2 or 3 letters, but I have been testing this and it allows as many letters as I put in there, but not 1 only. What's wrong? Also, when using eregi do I need to specify A-Za-z or just a-z, since it is case-insensitive? -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com [EMAIL PROTECTED] There is no reason anyone would want a computer in their home. --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
Chip, It's not so much off topic as a perennial topic - see archives and many tutorial articles. When you've worked out the answer to this question, please try out your algorithm on my (or any other 'foreign') address. Then consider the imminent introduction of further TLDs, eg .info (four characters), .family, etc. Regards, =dn PS Sorry, can't help with POSIX RegExs - I confuse myself without any outside assistance using the PCRE variants. I hope this isn't too far off topic - I have a regex for validating email addresses - if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-])+\. ([A-Za-z]{2,3})+$, $useremail)) Notice the {2,3} which is supposed to limit the last part to 2 or 3 letters, but I have been testing this and it allows as many letters as I put in there, but not 1 only. What's wrong? Also, when using eregi do I need to specify A-Za-z or just a-z, since it is case-insensitive? -- Chip Wiegand Computer Services Simrad, Inc www.simradusa.com [EMAIL PROTECTED] There is no reason anyone would want a computer in their home. --Ken Olson, president, chairman and founder of Digital Equipment Corporation, 1977 (They why do I have 9? Somebody help me!) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
On Thursday 22 August 2002 00:29, [EMAIL PROTECTED] wrote: I hope this isn't too far off topic - I have a regex for validating email addresses - if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-])+\. ([A-Za-z]{2,3})+$, $useremail)) Notice the {2,3} which is supposed to limit the last part to 2 or 3 letters, but I have been testing this and it allows as many letters as I put in there, but not 1 only. What's wrong? Also, when using eregi do I need to specify A-Za-z or just a-z, since it is case-insensitive? You're strongly advised not to write your own regex for validating email addresses. Your regex (once you get it working) will invalidate a lot of valid email addresses. Search archives, or google for some tried and tested regex which will do the job properly. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The most important things, each person must do for himself. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
Jason, Concur with your advice, but was also amused by its juxtaposition with your sig file philosophy... =dn [snipped] I have a regex for validating email addresses - You're strongly advised not to write your own regex for validating email /* The most important things, each person must do for himself. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
Jason Wong [EMAIL PROTECTED] wrote on 08/21/2002 10:00:23 AM: On Thursday 22 August 2002 00:29, [EMAIL PROTECTED] wrote: I hope this isn't too far off topic - I have a regex for validating email addresses - if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-]) +\. ([A-Za-z]{2,3})+$, $useremail)) Notice the {2,3} which is supposed to limit the last part to 2 or 3 letters, but I have been testing this and it allows as many letters as I put in there, but not 1 only. What's wrong? Also, when using eregi do I need to specify A-Za-z or just a-z, since it is case-insensitive? You're strongly advised not to write your own regex for validating email addresses. Your regex (once you get it working) will invalidate a lot of valid email addresses. Search archives, or google for some tried and tested regex which will do the job properly. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk This is from a php/mysql book. I added the parenthesis simply to group the sections, and added the {2,3} because a web site tutorial shows that will limit the preceding section to that many characters (2 or 3 only in this case). The script works fine without the {2,3}, and I may have to use it that way, since another response mentioned foreign addresses, I hadn't taken into account. I'd just like to know why it doesn't work, becuase the it's supposed to. -- Chip /* The most important things, each person must do for himself. */ Interesting tag considering your respoonse that I shouldn't do this mysqlf, eh? :-) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
On Thursday 22 August 2002 02:54, [EMAIL PROTECTED] wrote: This is from a php/mysql book. If they're presenting it as something that you can use in your real-life code then you should look carefully at all the other code in the book to see whether they're all as sloppy. On the other hand if they're only presenting it as an example on using regex then it's fine for learning with. I added the parenthesis simply to group the sections, and added the {2,3} because a web site tutorial shows that will limit the preceding section to that many characters (2 or 3 only in this case). The script works fine without the {2,3}, and I may have to use it that way, since another response mentioned foreign addresses, I hadn't taken into account. I'd just like to know why it doesn't work, becuase the it's supposed to. It's only checking for addresses of the form [EMAIL PROTECTED] As you can see, the list address ([EMAIL PROTECTED]), and my address ([EMAIL PROTECTED]) would be treated as invalid. Not very clever is it? -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* His great aim was to escape from civilization, and, as soon as he had money, he went to Southern California. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
On Thu, 22 Aug 2002 03:10:02 +0800 Jason Wong [EMAIL PROTECTED] wrote: On Thursday 22 August 2002 02:54, [EMAIL PROTECTED] wrote: As you can see, the list address ([EMAIL PROTECTED]), and my address ([EMAIL PROTECTED]) would be treated as invalid. Not very clever is it? Well, anyway there is only one sure way to valid email, confirmation message :-) pa -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
Jason Wong [EMAIL PROTECTED] wrote on 08/21/2002 12:10:02 PM: It's only checking for addresses of the form [EMAIL PROTECTED] As you can see, the list address ([EMAIL PROTECTED]), and my address ([EMAIL PROTECTED]) would be treated as invalid. Not very clever is it? Got it figured out, and foreign address do work now - if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-])+\.([A-Za-z])+\.([a-z])*$, $useremail)) -- Chip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
Regarding the good sense or otherwise for checking email addresses: This is from a php/mysql book... If it was from page 115, then please turn over to page 116! Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
Regarding the problem you are actually asking about: if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+([A-Za-z0-9\_-]) +\. ([A-Za-z]{2,3})+$, $useremail)) Notice the {2,3} which is supposed to limit the last part to 2 or 3 letters, but I have been testing this and it allows as many letters as I put in there, but not 1 only. What's wrong? Please be aware that I use PCRE not POSIX, but IIRC the last phrase says: ([A-Za-z]{2,3})+$ any upper or lower case letter, repeated twice or three times, and that appearing zero or more times, !!!??? appearing at the end of the string. Remove the + immediately before the terminating $. Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation question - regex not working
On Thursday 22 August 2002 04:01, [EMAIL PROTECTED] wrote: Got it figured out, and foreign address do work now - if (empty($useremail) || !eregi(^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-])+\.([A-Za-z])+\.([a-z])*$, $useremail)) What do you mean by 'foreign' addresses? The above will still fail for: [EMAIL PROTECTED] -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Dungeons and Dragons is just a lot of Saxon Violence. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php