Results 1 to 6 of 6

Thread: Verify password and regex

  1. #1
    Join Date
    Dec 2009
    Posts
    296

    Verify password and regex

    Hello,
    I would like to verify that a password does well:
    - At least a tiny
    - At least one uppercase
    - At least one number
    I struggle a bit with regex java, could you help me? For example, one of many attempts is:
    Code:
    password = "abcxyz";
    / / Test to check it's a word character
    		val = Pattern.games("\\w ", Password);
    		
    		if (val == true ) val = Pattern.games("[a-z]", Password);
    		if (val == true ) val = Pattern.games("[A-Z]", Password);
    		if (val == true ) val = Pattern.games("[0-9]", Password);
    The program is not running, if you have any idea about it then please let me know.

  2. #2
    Join Date
    Nov 2009
    Posts
    356

    Re: Verify password and regex

    Hello,
    You mean your boolean is "false" when the program runs. I have a code for you, that is this is not the exact code but the part of it , this may help you.
    Code:
    val= Pattern.games("\\w ", Password);
    Just include this in your code and see if the program runs or not. If you have any queries regarding this then please do post back.

  3. #3
    Join Date
    Nov 2009
    Posts
    446

    Re: Verify password and regex

    Hello,
    I have modified your code, see if it works for you.
    Here is the code
    Code:
    password = "abcxyz";
    / / Test to check it's a word character
    
          val = (Pattern.games("\\w + ", Password) & &
                        Pattern.games(".* [a-z] .*", Password) & &
                        Pattern.games(".* [A-Z] .*", Password) & &
                        Pattern.games(".*[0-9].*", Password));

  4. #4
    Join Date
    Dec 2009
    Posts
    296

    Re: Verify password and regex

    Hello,
    Thanks for your replies. A priority it goes, but I'll make a small battery of tests to test HTMLUnit more thing (and discover HTMLUnit the passage ). yes it crashes from the first line (well, put valid False). you can detail just why and simple .* *? I read the doc and I had not really understood it well. Any more help or information on this will be great and I am the interested one . So, please if you know something then please do post back.

  5. #5
    Join Date
    Nov 2009
    Posts
    343

    Re: Verify password and regex

    Hello,
    The regular expression "[az] means any character between a and z and nothing else. Your password must contain at least one character between a and z, but it may contain something else. So we add ".*" (. Means any character and * quantifier is 0 or N times) in front and behind to finally say that the password must contain anything with at least one character between a and z .
    Ditto for [A-Z] and [0-9].
    For the "\ \ w +", "\ \ w" (actually "\ w") means: 1 character provided it is between a and z, between A and Z, or between 0 and 9. It simply adds the "+" means 1 or N times (your password can make more than one character. Hope this information will help you.

  6. #6
    Join Date
    Dec 2009
    Posts
    296

    Re: Verify password and regex

    Hello,
    In fact, in my tests, I * and confused. * I used to say "any character". Regarding the number of character, my program itself ensures that this alone is good. Moreover, we can define patterns to validate entries. I'll have leaned on the issue, now that I know the regex is going well. Again, thanks for the help.

Similar Threads

  1. Windows mail asking to verify username and password
    By Beant in forum Windows Vista Mail
    Replies: 4
    Last Post: 26-03-2011, 04:11 AM
  2. Regex to verify email address
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 17-02-2010, 03:50 AM
  3. Regex to verify data
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 16-02-2010, 05:27 AM
  4. RegEx - verify content and size
    By New ID in forum Software Development
    Replies: 5
    Last Post: 04-02-2010, 01:27 AM
  5. please verify username and password are correct...
    By MR Gorman in forum Windows Vista Mail
    Replies: 3
    Last Post: 20-02-2009, 04:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,240,942.18493 seconds with 17 queries