import org.apache.commons.lang.CharSetUtils; public class MainClass { public static void main(String[] args) { //Keeps only the characters specified System.out.println("Keep B and o = " + CharSetUtils.keep("BorisBecker", "Bo")); } }
Keep B and o = BoB