0
Pattern.matches(".*[!@#$%^&*()-+].*","AUzs-nV");

Is returning false. Even though string pattern matching sequence contains "-" hyphen.

Ousmane D.
  • 54,915
  • 8
  • 91
  • 126
prasadn
  • 41
  • 3
  • escape it with `\\\` – Eugene Apr 05 '18 at 20:09
  • 1
    In a character class (delimited by `[]`), the hyphen needs to be escaped unless it is the first character in the class. Also, your initial wildcard quantifier should be reluctant instead of greedy (use `.*?` instead of `.*`). – Ted Hopp Apr 05 '18 at 20:10

0 Answers0