Aravind,
See below for an explanation of the regex:
^.(?=.{8,})(?=.[a-z])(?=.[A-Z])(?=.[\W_]).*$
^ asserts position at start of the string
. matches any character (except for line terminators)
Positive Lookahead (?=.{8,})
Assert that the Regex below matches
.{8,} matches any character (except for line terminators)
{8,} Quantifier — Matches between 8 and unlimited times, as many times as possible, giving back as needed (greedy)
Positive Lookahead (?=.[a-z])
Assert that the Regex below matches
. matches any character (except for line terminators)
Match a single character present in the list below [a-z]
a-z a single character in the range between a (ASCII 97) and z (ASCII 122) (case sensitive)
Positive Lookahead (?=.[A-Z])
Assert that the Regex below matches
. matches any character (except for line terminators)
Match a single character present in the list below [A-Z]
A-Z a single character in the range between A (ASCII 65) and Z (ASCII 90) (case sensitive)
Positive Lookahead (?=.[\W_])
Assert that the Regex below matches
. matches any character (except for line terminators)
Match a single character present in the list below [\W_]
\W matches any non-word character (equal to [^a-zA-Z0-9_])
_ matches the character _ literally (case sensitive)
.* matches any character (except for line terminators)
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
For all your regex needs, use regexr (or any other site like it). For your specific regex: http://regexr.com/3ebs4