vijdev Posted June 5, 2010 Share Posted June 5, 2010 I need to ensure a certain field input is: 1.having both alphabets and numerics 2.begins with uppercase alpha 3.must be min. 5 and max 10 characters in all. I am using ^[A-Z]{1}[A-Za-z0-9]{4,9}, but here are the drawbacks: 1.It does not mandate that a number exists in the input, it only ensures it is alphanumeric 2.ctype_alnum along with above regex also does not work. 3.I dont want to mandate that the numbers are only after the alphas(exception of 1st upper case alpha) Link to comment https://forums.phpfreaks.com/topic/203925-string-checking-issue/ Share on other sites More sharing options...
dabaR Posted June 5, 2010 Share Posted June 5, 2010 What if you split it into several checks? Link to comment https://forums.phpfreaks.com/topic/203925-string-checking-issue/#findComment-1068065 Share on other sites More sharing options...
vijdev Posted June 5, 2010 Author Share Posted June 5, 2010 dabar?how? Link to comment https://forums.phpfreaks.com/topic/203925-string-checking-issue/#findComment-1068152 Share on other sites More sharing options...
vijdev Posted June 5, 2010 Author Share Posted June 5, 2010 $input= "King623456789"; $basic_check = preg_match("/^[A-Z]{1}[A-Za-z0-9]{4,9}/", $input, $inputComponents); $checknum= preg_match("/[0-9]/", $input, $numComponents); if ($myDate){ if($checknum){ echo "All Ok!"; } else echo "no number"; } else echo "absolutely no match!"; anyone any comments? Link to comment https://forums.phpfreaks.com/topic/203925-string-checking-issue/#findComment-1068183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.