Home > AI > Backend > SpringBoot > commons-lang3 >

StringUtils

Step 1: install dependency

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
</dependency>

Step 2: StringUtils.java

@Test
    void hello() {
        String string = "jobyme88.com";
        boolean contained1 = StringUtils.containsAny(string, 'j', 'o', 'b');
        boolean contained2 = StringUtils.containsAny(string, 'h', 'l', 't');
        boolean contained3 = StringUtils.containsAny(string, "job");
        boolean contained4 = StringUtils.containsAny(string, "hlt");

        assertTrue(contained1);
        assertFalse(contained2);
        assertTrue(contained3);
        assertFalse(contained4);
    }
Related posts:
    No posts found.

Leave a Reply