Example usage for org.apache.commons.lang3 CharSetUtils delete

List of usage examples for org.apache.commons.lang3 CharSetUtils delete

Introduction

In this page you can find the example usage for org.apache.commons.lang3 CharSetUtils delete.

Prototype

public static String delete(final String str, final String... set) 

Source Link

Document

Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.

 CharSetUtils.delete(null, *)        = null CharSetUtils.delete("", *)          = "" CharSetUtils.delete(*, null)        =  CharSetUtils.delete(*, "")          =  CharSetUtils.delete("hello", "hl")  = "eo" CharSetUtils.delete("hello", "le")  = "ho" 

Usage

From source file:yoyo.framework.standard.shared.commons.lang.CharSetUtilsTest.java

@Test
public void test() {
    assertThat(CharSetUtils.count(null, "a-z"), is(0));
    assertThat(CharSetUtils.count("", "a-z"), is(0));
    assertThat(CharSetUtils.count("hello", "k-p"), is(3));
    assertThat(CharSetUtils.count("hello", "a-e"), is(1));
    assertThat(CharSetUtils.count("hello", "a", "b", "c", "d", "e"), is(1));
    assertThat(CharSetUtils.delete(null, "a-z"), is(nullValue()));
    assertThat(CharSetUtils.delete("", "a-z"), is(""));
    assertThat(CharSetUtils.delete("hello", "hl"), is("eo"));
    assertThat(CharSetUtils.keep(null, "a-z"), is(nullValue()));
    assertThat(CharSetUtils.keep("", "a-z"), is(""));
    assertThat(CharSetUtils.keep("hello", "hl"), is("hll"));
    assertThat(CharSetUtils.squeeze(null, "a-z"), is(nullValue()));
    assertThat(CharSetUtils.squeeze("", "a-z"), is(""));
    assertThat(CharSetUtils.squeeze("hello", "k-p"), is("helo"));
}