简体   繁体   English

如何查找一个字符串上有多少个数字和字母

[英]How to find how many numbers and letters are on a string

I'm validating passwords. 我正在验证密码。 I need to check how many letters and numbers there are in a password. 我需要检查密码中有多少个字母和数字。 If there were less than 2 numbers or less than 2 letters, the user should be warned about an invalid password. 如果少于2个数字或少于2个字母,则应警告用户密码无效。

For each character in the password, check against the ASCII table and count letters and numbers appearances: 对于密码中的每个字符,请对照ASCII表检查并计算字母和数字的出现:

在此处输入图片说明

Consider adding special characters to the validation. 考虑在验证中添加特殊字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM