How to determine if a String has non-alphanumeric characters?

后端 未结 8 1267
一向
一向 2020-11-27 02:44

I need a method that can tell me if a String has non alphanumeric characters.

For example if the String is \"abcdef?\" or \"abcdefà\", the method must return true.

8条回答
  •  时光说笑
    2020-11-27 03:19

    You have to go through each character in the String and check Character.isDigit(char); or Character.isletter(char);

    Alternatively, you can use regex.

提交回复
热议问题