Help!!! Trying to code this ASAP, and I\'m having the most issues with how to ch
ID: 664155 • Letter: H
Question
Help!!!
Trying to code this ASAP, and I'm having the most issues with how to check for upper/lower case, numbers, and symbols.) Thanks in advance for any help!
Function Name: checkPassword
Inputs:
1. (char) A string containing a user-provided password
Outputs:
1. (logical) A logical specifying if the password provided meets the given criteria
Function Description:
In the recent security leaks of various corporations, passwords have to be more complex
than ever (and since we’re at Tech, we all know this). Write the MATLAB function
checkPassword that takes in a string containing a password and determines if it meets the
criteria. It should output true if it does meet the criteria and false if it does not.
Criteria:
The string must contain at least 8 characters (8 OR above).
The string must contain at least 1 number, 1 lowercase letter, and 1 uppercase letter.
The string must contain at least 1 symbol that ranges from a space to a forward slash
(‘/’) on the ascii table.
Further, if the password to be checked contains the word password (or any of its
upper/lowercase permutations), it automatically does not pass the check and should return
false.
Example:
Notes:
o passworD1$ – false
o 20/passWord15 – false
o PaSSword!3@ - false
o p%as2015Sword – true
It is acceptable to use symbols that are not in the specified range, but there must be at
least 1 symbol that is from the specified range.
Hints:
The strfind() function may be helpful.
Explanation / Answer
1) str='password';
expression="*str*";
boolean(regexp(str,expression,'match','ignorecase')
2)regexp(?=^.{8,}$)((?=.*d)|(?=.*W+))(?![. ])(?=.*[A-Z])(?=.*[a-z]).*$
The first regular expression checks if the word "password" is present in the the expression and the second regular expressio checks for the rest of the conditions mentioned in the question.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.