Nandini Posted May 20, 2010 Share Posted May 20, 2010 Hi I want to check atleast one number and one letter in php string using regular expressions. I am using the followinf snippet. But thats not working me fine. Please help me. here is my code $reg="/^[a-z0-9]{1,}$/"; if(preg_match($reg, $_POST['string'])) { $e="String should be atleast one letter and one number"; } pls help me out. Thanq Link to comment https://forums.phpfreaks.com/topic/202345-check-atleast-one-number-and-one-letter-in-php-string/ Share on other sites More sharing options...
Nandini Posted May 20, 2010 Author Share Posted May 20, 2010 Ya i got a solution like this $reg="/^.*(?=.{6,})(?=.*\\d)(?=.*[a-zA-Z]).*$/"; This will check minimum of 6 length and atleast one letter and one number Thanq Link to comment https://forums.phpfreaks.com/topic/202345-check-atleast-one-number-and-one-letter-in-php-string/#findComment-1060959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.