September 6, 200818 yr Hi all, Think im close to figuring this one, but I keep messing and it is not working. Basically I want the php to validate all strings as true if they are [:alnum:]. However, my script is only returning the last string as "1". (seems it only accepts 1 character strings). what amendment do I need to make to say the whole string (can be any string size) has to be [:alnum:]? the Code: <?php function CharNum_RegExp_Validate($string){ $pattern = "^[:alnum:]+$"; if (eregi($pattern, $string)) { return "1"; }else{ return "0"; } } echo CharNum_RegExp_Validate("string01"); echo CharNum_RegExp_Validate("string.01"); echo CharNum_RegExp_Validate("1string"); echo CharNum_RegExp_Validate("string01^"); echo CharNum_RegExp_Validate("a"); ?> The Result: 00001 The Wanted Result: 10101
September 8, 200818 yr Author I know that we are not meant to bump, but kinda been waiting quite a while for this one... and I need the answer like ASAP!. ...bump!
September 8, 200818 yr Author Topic Resolved. For future referance for anyone visiting this thread.... fix: function alnum_validate($string){ if (ctype_alnum($string)){ return "1"; }else{ return "0"; } }
Create an account or sign in to comment