Here you can find the source of cutWordsAll(String src, String contains)
public static String cutWordsAll(String src, String contains)
//package com.java2s; public class Main { public static String cutWordsAll(String src, String contains) { String result = cutWords(src, contains); if (result.indexOf(contains) != -1) { return cutWordsAll(result, contains); }/*from w w w. j av a 2 s.co m*/ return result; } public static String cutWords(String src, String contains) { int begin = src.indexOf(contains); if (begin == -1) { return src; } int end = begin + contains.length(); String beginStr = ""; if (begin != 0) { beginStr = src.substring(0, begin); } String endStr = ""; if (end < src.length()) { endStr = src.substring(end); } return beginStr + endStr; } }