use strict;use warnings;use YAPE::Regex::Explain;print YAPE::Regex::Explain->new("^(?=.{8,})(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^A-Za-z0-9]).*\$")->explain;__END__RESULT:(?-imsx:^(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^A-Za-z0-9]).*$)matches as follows:NODE EXPLANATION----------------------------------------------------------------------(?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally):---------------------------------------------------------------------- ^ the beginning of the string---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .{8,} any character except \n (at least 8 times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- \d digits (0-9)---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- [a-z] any character of: 'a' to 'z'---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- [A-Z] any character of: 'A' to 'Z'---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- [^A-Za-z0-9] any character except: 'A' to 'Z', 'a' to 'z', '0' to '9'---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- $ before an optional \n, and the end of the string----------------------------------------------------------------------) end of grouping----------------------------------------------------------------------
"^(?:[A-Za-z0-9]*)$
"^(?:[A-Za-z0-9]{8,})$
"^\w*$" -or- "^\w{8,}$"
i was tryin to implement following password policymin 8charsone lower case letter minone upper case letter minone special char minone digit min
^(?=.{8,})(?=.*\d.*)(?=.*[a-z].*)(?=.*[A-Z].*)(?.=[^A-Za-z0-9].*)$[indent]NODE EXPLANATION----------------------------------------------------------------------(?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally):---------------------------------------------------------------------- ^ the beginning of the string---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .{8,} any character except \n (at least 8 times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- \d digits (0-9)---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- [a-z] any character of: 'a' to 'z'---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- [A-Z] any character of: 'A' to 'Z'---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead----------------------------------------------------------------------) end of grouping----------------------------------------------------------------------[/indent]
^(?=.{8,})(?=.*\w.*)(?=.*\W.*)$[indent]NODE EXPLANATION----------------------------------------------------------------------(?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally):---------------------------------------------------------------------- ^ the beginning of the string---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .{8,} any character except \n (at least 8 times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- \w word characters (a-z, A-Z, 0-9, _)---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- (?= look ahead to see if there is:---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- \W non-word characters (all but a-z, A-Z, 0-9, _)---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible))---------------------------------------------------------------------- ) end of look-ahead---------------------------------------------------------------------- $ before an optional \n, and the end of the string----------------------------------------------------------------------) end of grouping----------------------------------------------------------------------[/indent]
(ORIGINAL): /^(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^A-Za-z0-9]).*$/(OPTION-1): /^(?=.{8,})(?=.*\d.*)(?=.*[a-z].*)(?=.*[A-Z].*)(?.=[^A-Za-z0-9].*)$/(OPTION-2): /^(?=.{8,})(?=.*\w.*)(?=.*\W.*)$/