Why is String.matches returning false in Java?

前端 未结 3 1137
太阳男子
太阳男子 2020-12-11 17:56
if(\"test%$@*)$(%\".matches(\"[^a-zA-Z\\\\.]\"))
    System.exit(0);

if(\"te/st.txt\".matches(\"[^a-zA-Z\\\\.]\"))
    System.exit(0);

The program

3条回答
  •  孤街浪徒
    2020-12-11 18:46

    You obtain always false because the matches() method return true only when the pattern matches the full string.

提交回复
热议问题