Home  >  Article  >  Backend Development  >  php限制只能输入英文字符和数字的正则表达式

php限制只能输入英文字符和数字的正则表达式

WBOY
WBOYOriginal
2016-06-20 13:03:413095browse

php限制只能输入英文字符和数字,正则表达式如下:

<p>$password='abc12';</p>if(!preg_match("/^(([a-z]+[0-9]+)|([0-9]+[a-z]+))[a-z0-9]*$/i",$password)){<br />	echo '密码必须由数字和字母的组合而成';<br /><p>}</p>

php限制只能输入6-15位的英文字符和数字,正则表达式如下:

<p>$password='abc123';</p>$plen=strlen($password);<br />if(!preg_match("/^(([a-z]+[0-9]+)|([0-9]+[a-z]+))[a-z0-9]*$/i",$password)||$plen<6||$plen>15){<br />	echo '密码必须为6-15位的数字和字母的组合';<br />}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn