Josh C
Josh C

Reputation: 57

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.

Upvotes: 1

Views: 187

Answers (1)

cahen
cahen

Reputation: 16636

For each character in the password, check against the ASCII table and count letters and numbers appearances:

enter image description here

Consider adding special characters to the validation.

Upvotes: 0

Related Questions