Java by API/org.apache.commons.lang/CharSetUtils
Содержание
CharSetUtils: count(String str, String set)
<source lang="java">
/* B and o count = 3 B,o,k,e and r count = 8
*/
import org.apache.rumons.lang.CharSetUtils; public class CharSetUtilsTrial {
public static void main(String[] args) { // Count all occurrences of all the characters specified. System.out.println("B and o count = " + CharSetUtils.count("BorisBecker", "Bo")); // 3 System.out.println("B,o,k,e and r count = " + CharSetUtils.count("BorisBecker", new String[] { "Bo", "ker" })); // 8 }
}
</source>
CharSetUtils: count(String str, String[] set) (2)
<source lang="java">
/* B and o count = 3 B,o,k,e and r count = 8
*/
import org.apache.rumons.lang.CharSetUtils; public class CharSetUtilsTrial {
public static void main(String[] args) { // Count all occurrences of all the characters specified. System.out.println("B and o count = " + CharSetUtils.count("BorisBecker", "Bo")); // 3 System.out.println("B,o,k,e and r count = " + CharSetUtils.count("BorisBecker", new String[] { "Bo", "ker" })); // 8 }
}
</source>
CharSetUtils: delete(String str, String set)
<source lang="java">
/* Delete B and o = risecker Delete B,o,k,e and r = isc
*/
import org.apache.rumons.lang.CharSetUtils; public class CharSetUtilsTrial {
public static void main(String[] args) { // Specified characters deleted. System.out.println("Delete B and o = " + CharSetUtils.delete("BorisBecker", "Bo")); // risecker System.out.println("Delete B,o,k,e and r = " + CharSetUtils.delete("BorisBecker", new String[] { "Bo", "ker" })); // isc }
}
</source>
CharSetUtils: delete(String str, String[] set) (2)
<source lang="java">
/* Delete B and o = risecker Delete B,o,k,e and r = isc
*/
import org.apache.rumons.lang.CharSetUtils; public class CharSetUtilsTrial {
public static void main(String[] args) { // Specified characters deleted. System.out.println("Delete B and o = " + CharSetUtils.delete("BorisBecker", "Bo")); // risecker System.out.println("Delete B,o,k,e and r = " + CharSetUtils.delete("BorisBecker", new String[] { "Bo", "ker" })); // isc }
}
</source>
CharSetUtils: keep(String str, String set)
<source lang="java">
/* Keep B and o = BoB Squeeze B and o = Borisbbbecker
*/
import org.apache.rumons.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 }
}
</source>
CharSetUtils: squeeze(String str, String set)
<source lang="java">
/* Keep B and o = BoB Squeeze B and o = Borisbbbecker
*/
import org.apache.rumons.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 }
}
</source>