I have found great answer here with explanation to make sure that a given string contains at least one character from each of the following categories.
Lowercase character,
Uppercase character,
Digit,
Symbol
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*(_|[^\w])).+$
A short explanation:
^
// the start of the string
(?=.*[a-z])
// use positive look ahead to see if at least one lower case letter exists
(?=.*[A-Z])
// use positive look ahead to see if at least one upper case letter exists
(?=.*\d)
// use positive look ahead to see if at least one digit exists
(?=.*[_\W])
// use positive look ahead to see if at least one underscore or non-word character exists
.+
// gobble up the entire string
$
// the end of the string
Hope that help you.