Use the constructor function when you know the regular expression pattern will be changing, or you don't know the pattern and are getting it from another source, such as user input.

validating charater strings using javascript-74validating charater strings using javascript-55validating charater strings using javascript-59

=.*[@#$%]) # must contains one special symbols in the list "@#$%" . mkyo Ng12* , special symbol “*” is not allow here 4. MKYONG12$ , lower case character is required Unit test with Test NG.

# match anything with previous condition checking # length at least 6 characters and maximum of 20 ) # End of group Whole combination is means, 6 to 20 characters string with at least one digit, one upper case letter, one lower case letter and one special symbol (“@#$%”). Password is valid : [email protected] , true Password is valid : mk YOn12$ , true Password is valid : m [email protected] , false Password is valid : [email protected] , false Password is valid : mkyo Ng12* , false Password is valid : mkyon G$$ , false Password is valid : MKYONG12$ , false PASSED: Valid Password Test([ String;@116471f) =============================================== com.mkyong.regex.

The following Javascript uses the test() method tests for a match in a string.

This method returns true if it finds a match, otherwise it returns false.

The last example includes parentheses which are used as a memory device.

The match made with this part of the pattern is remembered for later use, as described in Using parenthesized substring matches.

One string will represent what is required for creating a strong password and the other will represent what is necessary for creating a medium strength password.

If neither expressions are satisfied, we’ll assume it is poor strength.

Reg Ex is nice because you can accomplish a whole lot with very little.