@@ -0,0 +1,1595 @@
+package com.levelup.java.string;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport org.apache.commons.lang3.StringUtils;%0Aimport org.junit.Test;%0A%0Aimport com.google.common.base.CharMatcher;%0A%0A/**%0A * This java example will demonstrate removing chars%0A * from string.%0A * %0A * @author Justin Musgrove%0A * @see %3Ca href='http://www.leveluplunch.com/java/'%3E%3C/a%3E%0A * %0A */%0Apublic class RemoveCharsFromString %7B%0A%0A%09@Test%0A%09public void remove_chars_from_java () %7B%0A%09%09%0A%09%09String parsedTelePhoneNumber = %22920-867-5309%22.replace(%22-%22, %22%22);%0A%09%09assertEquals(%229208675309%22, parsedTelePhoneNumber);%0A%0A%09%7D%0A%0A%09@Test%0A%09public void remove_all_special_chars_from_java () %7B%0A%0A%09%09String parsedTelePhoneNumber = %22+920-867-5309%22.replaceAll(%22%5B%5C%5CD%5D%22, %22%22);%0A%09%09assertEquals(%229208675309%22, parsedTelePhoneNumber);%0A%0A%09%7D%0A%09%0A%09@Test%0A%09public void remove_char_from_string_guava () %7B%0A%09%09%0A%09%09String telephoneNumber = CharMatcher.inRange('0','9').retainFrom(%22920-867-5309%22);%0A%09%09assertEquals(%229208675309%22, telephoneNumber);%0A%09%09%0A%09%09// worried about performance%0A%09%09CharMatcher digits = CharMatcher.inRange('0','9').precomputed();%0A%09%09String teleNumber = digits.retainFrom(%22920-867-5309%22);%0A%09%09assertEquals(%229208675309%22, teleNumber);%0A%09%09%0A%09%7D%0A%09%0A%09@Test%0A%09public void remove_char_from_string_apache_commons () %7B%0A%09%09%0A%09%09String parsedTelephoneNumber = StringUtils.remove(%22920-867-5309%22, '-');%0A%09%09assertEquals(%229208675309%22, parsedTelephoneNumber);%0A%0A%09%7D%0A%09%0A%09@Test%0A%09public void remove_char_from_string_spring () %7B%0A%09%09%0A%09%09String parsedTelephoneNumber = org.springframework.util.%0A%09%09%09%09StringUtils.replace(%22920-867-5309%22, %22-%22, %22%22);%0A%09%09assertEquals(%229208675309%22, parsedTelephoneNumber);%0A%0A%09%7D%0A%09%0A%7D%0A

add remove chars from string