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

后端 未结 8 1104
一向
一向 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

    Though it won't work for numbers, you can check if the lowercase and uppercase values are same or not, For non-alphabetic characters they will be same, You should check for number before this for better usability

    0 讨论(0)
  • 2020-11-27 03:22

    If you can use the Apache Commons library, then Commons-Lang StringUtils has a method called isAlphanumeric() that does what you're looking for.

    0 讨论(0)
提交回复
热议问题