How do I check if a string contains a list of characters?

后端 未结 8 758
小鲜肉
小鲜肉 2020-12-11 02:02

How do I check if a list of characters are in a String, for example \"ABCDEFGH\" how do I check if any one of those is in a string.

8条回答
  •  青春惊慌失措
    2020-12-11 02:40

    Use Apache Commons StringUtils.containsAny()..satisfies a lot of different use cases one might have for checking if certain characters exist in a string.

    https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#containsAny-java.lang.CharSequence-char...-

提交回复
热议问题