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

后端 未结 8 745
小鲜肉
小鲜肉 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:05

    use regular expression in java to check using str.matches(regex_here) regex in java

    for example:

        if("asdhAkldffl".matches(".*[ABCDEFGH].*"))
        {
            System.out.println("yes");
        }
    

提交回复
热议问题