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) Quote 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? Quote 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? Quote 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? Quote Link to comment https://forums.phpfreaks.com/topic/203925-string-checking-issue/#findComment-1068183 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.