CharSetUtils: keep(String str, String set) : CharSetUtils « org.apache.commons.lang « Java by API






CharSetUtils: keep(String str, String set)

/*
Keep B and o = BoB
Squeeze B and o = Borisbbbecker
 */
import org.apache.commons.lang.CharSetUtils;

public class CharSetUtilsTrial {
  public static void main(String[] args) {

    // Keeps only the characters specified
    System.out.println("Keep B and o = " + CharSetUtils.keep("BorisBecker", "Bo")); // BoB

    // Removes specified character repetitions
    System.out.println("Squeeze B and o = " + CharSetUtils.squeeze("BBoooorisbbbecker", "Bo")); // Borisbbbecker

  }
}

           
       








Apache-Common-Lang.zip( 248 k)

Related examples in the same category

1.CharSetUtils: count(String str, String set)
2.CharSetUtils: count(String str, String[] set) (2)
3.CharSetUtils: delete(String str, String set)
4.CharSetUtils: delete(String str, String[] set) (2)
5.CharSetUtils: squeeze(String str, String set)