Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to validate a password using regular expression in R?

Description

To validate a password using regular expression in R

Process

  Load the password

  Check whether the length of the password is greater than zero

  Check whether it contains at least one upper case letter

  Check whether it contains at least one lower case letter

  Check whether it contains at least one digit

  Check whether it doesn’t contain white space

  If all the above conditions are met then it is a good choice of password

Sapmle Code

pw=readline(prompt = “Enter the password : “)
i=0
if(nchar(pw)<8)
{
i=1
cat(“The Password is too short\n”)
}
if(grepl(“[[:upper:]]”,pw)==FALSE)
{
i=1
cat(“Password must contain atleast one Upper case letter\n”)
}
if(grepl(“[[:lower:]]”,pw)==FALSE)
{
i=1
cat(“Password must contain atleast one Lower case letter\n”)
}
if(grepl(“[[:digit:]]”,pw)==FALSE)
{
i=1
cat(“Password must contain atleast one digit\n”)
}
if(grepl(“[[:space:]]”,pw)==TRUE)
{
i=1
cat(“The password mustnot contain white space\n”)
}
if(i==0)
{
cat(“Good choice of password”)
}else
{
cat(“Please Retry”)
}

Screenshots
validate a password using regular expression in R
Load the password
Cheack whether the length of the password is greater than zero
Check whether it contains at least one lower case letter
Check whether it contains at least one digit