Regex for password

Reply

Join Date: Jun 2005
Posts: 1
Reputation: matvrix is an unknown quantity at this point 
Solved Threads: 0
matvrix matvrix is offline Offline
Newbie Poster

Regex for password

 
0
  #1
Jun 13th, 2005
It there a way to validate a string that

>> Does not use characters like #$@ in the password.
>> It must contain 1 upper case letter, 1 lower case letter, 1 number & must end in a letter.
>> It must be 6-11 characters

using Regular Exp ?

Any pointer would be greatly apprecaited.

Cheers !
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 23
Reputation: gritty is an unknown quantity at this point 
Solved Threads: 0
gritty gritty is offline Offline
Newbie Poster

Re: Regex for password

 
0
  #2
Jul 22nd, 2005
there are several different kinds of regex, is this for a passwd script?
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 23
Reputation: gritty is an unknown quantity at this point 
Solved Threads: 0
gritty gritty is offline Offline
Newbie Poster

Re: Regex for password

 
0
  #3
Jul 22nd, 2005
some pretty standard ones are [A-Z] && [a-z] && [0-9], that should at least get you through the must require cap letters, lowercase letters and a number. The rest will depend on what you are running, such as awk, sed, grep, etc....
Let me know if this helps and what you are running this on and I'll be glad to help ya out.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Regex for password

 
0
  #4
Jul 23rd, 2005
I am kind of learning as I go. you are able to test for length of a string using this method
Shell Scripting Syntax (Toggle Plain Text)
  1. var='abcdef'
  2. echo ${#var}

so this will test for a variable with the lengths inbetween 6 and 11
Shell Scripting Syntax (Toggle Plain Text)
  1. #!/bin/bash
  2. echo "enter your password"
  3. read PASS
  4. if ((${#PASS} >= 6)) && ((${#PASS} <= 11))
  5. then echo "password has been accepted"
  6. fi
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Regex for password

 
0
  #5
Jul 23rd, 2005
this will check if the lenght is between 6 and 11
Shell Scripting Syntax (Toggle Plain Text)
  1. ((${#PASS} >= 6)) && ((${#PASS} <= 11))

this will check if you have at least one lowecase letter
Shell Scripting Syntax (Toggle Plain Text)
  1. [[ $VAR == *[a-z]* ]]

this will check if you have at least one uppercase letter
Shell Scripting Syntax (Toggle Plain Text)
  1. [[ $VAR == *[A-Z]* ]]

this will check if you have at least one number
Shell Scripting Syntax (Toggle Plain Text)
  1. [[ $VAR == *[1-9]* ]]

this will check if you have a letter at the end, either upper or lowercase
Shell Scripting Syntax (Toggle Plain Text)
  1. [[ $VAR == *[a-zA-Z] ]]

I am not sure(yet) how to determine if all of the chartacters are iether numbers, or letters, no special character. Example $%&^.

I will let you know what I figure out :-)
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Regex for password

 
0
  #6
Jul 23rd, 2005
you can use this to check to see if your script has any characters other then numbers or letters
Shell Scripting Syntax (Toggle Plain Text)
  1. [[ ${VAR} == *[^a-bA-B1-9]* ]]
this will return a 0 if any non letters or numbers are found.

It would be very easy to combine all of these tests into a single script. I learned quite abit myself while looking for this info :-)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC