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

后端 未结 8 760
小鲜肉
小鲜肉 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 03:02

    From Guava: CharMatcher.matchesAnyOf

    private static final CharMatcher CHARACTERS = CharMatcher.anyOf("ABCDEFGH");
    assertTrue(CHARACTERS.matchesAnyOf("39823839A983923"));
    

提交回复
热议问题