Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Regular expression

    Hi All,

    I want regular expression for the following criteria
    Contain eight characters or more
    Contain characters from two of the following three character classes:
    1. Alphabetic (e.g., a-z, A-Z)
    2. Numeric (i.e. 0-9)
    3. Punctuation and other characters (e.g., !@#$%^&*()_+|~-=\`{}[]:";'<>?,./)


    Please send reply as soon as possible

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,080
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by sushanttanawade View Post
    Please send reply as soon as possible
    What did you last servant die of?

    It is not too practical to combine your conditions (two out of three) into just one regular expression.

    I interpret Contain characters to mean contains at least one character from two of the three categories you mention.

    Code:
    <script type = "text/javascript">
    var str = "abc123_?&@"
    var flag = 0;
    var len = str.length;
    if (/[a-z]/gi.test(str)) {flag++}
    if (/[0-9]/g.test(str)) {flag++}
    if (/\W|\_/g.test(str)) {flag++}
    if ((flag >=2) && (len>=8)) {
    alert ("Password " + str + " meets the criteria and is valid");
    }
    else {
    alert ("Invalid password!");
    }
    </script>
    It has been mentioned recently in this forum that the security of a password is much more sensitive to its length than to the inclusion of numbers and/or punctuation. In other words 9 alpha-numeric characters is more secure (harder to crack) than 8 characters from the full range of alpha-numeric and punctuation. Just a thought.

    "We have created a window of opportunity and it is time to walk through that window." - Local politician
    Last edited by Philip M; 06-16-2009 at 01:20 PM.

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanx

    Thanx Philip
    It is working actually that was client requirement I will consider your suggestions for next development

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,080
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    The problem with passwords such as xG5%uLm7 is that no-one can remember them, so they tend to be written down on a piece of paper under the mousemat.

    For myself, I prefer long but semi-meaningful passwords which can be remembered, using two unrelated words (perhaps in a foreign language) separated by a digit or two.

    Example:
    purple84starling
    Mokumse67Gozer

    I believe that such a 14+ character password cannot be broken in under thousands or millions of years.
    Last edited by Philip M; 06-16-2009 at 01:34 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •