[PHP] eregi problem
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
Re: [PHP] eregi problem
[EMAIL PROTECTED] wrote: I m trying to check $GP[sifre] variable, $GP[sifre] must consist of alpha numeric chars only. here, how I check the variable: Try this: if(eregi(^[a-zA-Z0-9]+$,$GP[sifre])) The above say that between the beginning of the string ^ and the end of the string $, there are only alpha-numeric characters but at least one. Note, your following code has syntax error. Best Bao 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
Re: [PHP] eregi problem
[EMAIL PROTECTED] wrote: if((eregi([^a-zA-Z0-9],$GP[sifre]) I think that the ^ anchor is your problem, it shall be out of the brackets : if (eregi(^[a-zA-Z0-9]+$, $GP['sifre'])) echo 'true'; else echo 'false'; (the above is tested and works perfect) P.S. Take a look here http://www.php.net/manual/en/language.types.array.php#language.types.array.donts -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] eregi() problem
On Mon, 22 Apr 2002, Gregor Jaksa wrote: if (!eregi(^[[:alpha:]]$, $HTTP_POST_VARS[vpis_ime])) echo wrong char; why does this always return wrong char no matter what value is in vpis_ime ... i tried blah, 242234 bla242h .. every single time i get wrong char. im using PHP 4.1.2 The only thing that will match that regex is a single alpha character. Try ^[[:alpha:]]+$ (I added a plus) to match one or more. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] eregi() problem
if (!eregi(^[[:alpha:]]$, $HTTP_POST_VARS[vpis_ime])) echo wrong char; why does this always return wrong char no matter what value is in vpis_ime ... i tried blah, 242234 bla242h .. every single time i get wrong char. im using PHP 4.1.2 basicly is what i want is to check string if it contains only charaters from a to z and chars _ - [ ] . Can somebody write me a working function ? thx in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] eregi() problem
Try: if (!eregi('^[a-z_\-]{0,}$', $_POST['vpis_ime'])) echo wrong char; That'll sort it for everything except [ and ], which I can't find any way of checking for :-( Anyone else have any ideas? HTH anyway. Danny. - Original Message - From: Gregor Jaksa [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 22, 2002 1:04 AM Subject: [PHP] eregi() problem if (!eregi(^[[:alpha:]]$, $HTTP_POST_VARS[vpis_ime])) echo wrong char; why does this always return wrong char no matter what value is in vpis_ime ... i tried blah, 242234 bla242h .. every single time i get wrong char. im using PHP 4.1.2 basicly is what i want is to check string if it contains only charaters from a to z and chars _ - [ ] . Can somebody write me a working function ? thx in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php