Skip to content

Instantly share code, notes, and snippets.

@zainaali
Created October 16, 2018 21:56
Show Gist options
  • Save zainaali/248defd6ff03ff4ebd84d8da173ee586 to your computer and use it in GitHub Desktop.
Save zainaali/248defd6ff03ff4ebd84d8da173ee586 to your computer and use it in GitHub Desktop.
password must contain only numbers and letters with limit regex
<?php $password = 'abc';
if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,12}$/', $password) ) {
$error['password_length'] = "Password must be at least 6 characters, containing at least one latter and one number";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment