RE: [PHP] Re: eregi problem
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, April 03, 2005 6:03 PM To: php-general@lists.php.net Subject: [PHP] Re: eregi problem i'm not familliar with regular expresions but i think that ^a-z - means that variable must start witx a-z characters you can chek it here: http://www.php.net/manual/en/reference.pcre.pattern.syntax.php True, but look careful at what HE did: if((eregi([^a-zA-Z0-9],$GP[sifre]) Putting the ^ _inside_ [] means NOT, so if any of the chars a-z0-9 is in the string it´s NOT matched. Also there´s no idea in having a-zA-Z in the pattern since eregi() is case insensitive. -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: eregi problem
Kim Madsen wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, April 03, 2005 6:03 PM To: php-general@lists.php.net Subject: [PHP] Re: eregi problem i'm not familliar with regular expresions but i think that ^a-z - means that variable must start witx a-z characters you can chek it here: http://www.php.net/manual/en/reference.pcre.pattern.syntax.php True, but look careful at what HE did: if((eregi([^a-zA-Z0-9],$GP[sifre]) Putting the ^ _inside_ [] means NOT, so if any of the chars a-z0-9 is in the string it´s NOT matched. actually, that's not entirely correct. The regexp basically means that if there is any character in the string which is NOT alphanumeric, then it is matched. So basically it returns true if there is a non-alphanumeric char, and false otherwise. However, AFAIK the regexp should be delimited, since if it isn't it behaves differently... I just can't remember how differently it is exactly =/ Also there´s no idea in having a-zA-Z in the pattern since eregi() is case insensitive. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: eregi problem
-Original Message- From: M. Sokolewicz [mailto:[EMAIL PROTECTED] Sent: Monday, April 04, 2005 3:08 PM Putting the ^ _inside_ [] means NOT, so if any of the chars a-z0-9 is in the string it´s NOT matched. actually, that's not entirely correct. The regexp basically means that if there is any character in the string which is NOT alphanumeric, then it is matched. So basically it returns true if there is a non-alphanumeric char, and false otherwise. However, AFAIK the regexp should be delimited, since if it isn't it behaves differently... I just can't remember how differently it is exactly =/ It _is_ correct. [^] means that whatever is in the [] must not be in the checked var to be true! Look in mastering regular expressions if You´re in doubt. There´s an example [^1-6] meaning if a digit between 1 and 6 is not in the value checked, it´s true: $var1 = 123; $var2 = 789; if(ereg([^1-6], $var1)) print $var1 is true; else print $var1 is false; returns false if(ereg([^1-6], $var2)) print $var2 is true; else print $var2 is false; returns true It´s untested though :-) -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: eregi problem
Kim Madsen wrote: -Original Message- From: M. Sokolewicz [mailto:[EMAIL PROTECTED] Sent: Monday, April 04, 2005 3:08 PM Putting the ^ _inside_ [] means NOT, so if any of the chars a-z0-9 is in the string it´s NOT matched. actually, that's not entirely correct. The regexp basically means that if there is any character in the string which is NOT alphanumeric, then it is matched. So basically it returns true if there is a non-alphanumeric char, and false otherwise. However, AFAIK the regexp should be delimited, since if it isn't it behaves differently... I just can't remember how differently it is exactly =/ It _is_ correct. [^] means that whatever is in the [] must not be in the checked var to be true! Look in mastering regular expressions if You´re in doubt. There´s an example [^1-6] meaning if a digit between 1 and 6 is not in the value checked, it´s true: which is exactly what I said... $var1 = 123; $var2 = 789; if(ereg([^1-6], $var1)) print $var1 is true; else print $var1 is false; returns false if(ereg([^1-6], $var2)) print $var2 is true; else print $var2 is false; returns true It´s untested though :-) I just wasn't too sure about absence of the regexp-delimiter... -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: eregi problem
i'm not familliar with regular expresions but i think that ^a-z - means that variable must start witx a-z characters you can chek it here: http://www.php.net/manual/en/reference.pcre.pattern.syntax.php [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I m trying to check $GP[sifre] variable, $GP[sifre] must consist of alpha numeric chars only. here, how I check the variable: if((eregi([^a-zA-Z0-9],$GP[sifre]) echo 'true'; else echo 'false'; It works if variable starts with alphabetic chars only. for example this returns 'ok' $GP[sifre]='blabla234243'; but this does not work: (if variable starts with numeric chars) $GP[sifre]='3243242blabla'; second one returns false, couldnt figure out the problem here. any help ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: eregi problem
I really dont know :) [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I m trying to check $GP[sifre] variable, $GP[sifre] must consist of alpha numeric chars only. here, how I check the variable: if((eregi([^a-zA-Z0-9],$GP[sifre]) echo 'true'; else echo 'false'; It works if variable starts with alphabetic chars only. for example this returns 'ok' $GP[sifre]='blabla234243'; but this does not work: (if variable starts with numeric chars) $GP[sifre]='3243242blabla'; second one returns false, couldnt figure out the problem here. any help ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: eregi problem
you'd be better off with something like if(preg_match('#^[a-z0-9]+$#i', $GP['sifre'])) { echo 'contains only alphanumeric chars'; } else { echo 'contains characters which are not alphanumeric'; } - tul [EMAIL PROTECTED] wrote: I really dont know :) [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I m trying to check $GP[sifre] variable, $GP[sifre] must consist of alpha numeric chars only. here, how I check the variable: if((eregi([^a-zA-Z0-9],$GP[sifre]) echo 'true'; else echo 'false'; It works if variable starts with alphabetic chars only. for example this returns 'ok' $GP[sifre]='blabla234243'; but this does not work: (if variable starts with numeric chars) $GP[sifre]='3243242blabla'; second one returns false, couldnt figure out the problem here. any help ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php