RegEx Help

Discussion in 'Programming' started by westside415, Jul 7, 2010.

  1. #1
    Hi,


    I'm awful with regular expressions most likely because I haven't spent much time writing them but I'd like to have one that does the following


    Requirements


    1. Must be a minimum of 7 characters


    2. Must have at least 3 out 4 of the following

    2a) 1 Uppercase letter

    2b) 1 Lowercase letter

    2c) 1 Number

    2d) 1 Symbol


    So I want to pass in a string, and then run it against a regex that does the above.


    Any help appreciated

    -Westside415
     
    westside415, Jul 7, 2010 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You're not going get all that in a single regex. Not one you'll be able to understand anyway ;)

    I won't write it for you, but if you use posix expressions, it's not hard. They read like plain english: [:lower:], [:upper:], [:digit:], etc..

    Start with a score of 0 and check for lower case letters. Then increment the score if a match is found

    <cfset score = 0>
    <cfif reFind("[[:lower:]]", str)>
    <!--- found. increment the score --->
    <cfset score++>
    </cfif>
    ...... etc

    Do similar tests for the other categories, and check the score at the end. If it's 3 or higher return true. Make sense?
     
    cfStarlight, Jul 8, 2010 IP
  3. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you're going to ask multiple people to spend their time on your question, it would be nice to at least let them know when you already found an answer. So they don't waste any more of their time ... ;-)
    http://forums.adobe.com/message/2961942
     
    cfStarlight, Jul 11, 2010 IP