Advertisement
bekanaveriani

withoutString

Jul 21st, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. public String withoutStringProblem(String base, String remove, StringBuilder result, Integer lastIndexOf) {
  2.         int startSubst = lastIndexOf != null ? lastIndexOf+remove.length() : 0;
  3.         int indexOf = base.toUpperCase().substring(startSubst, base.length()).indexOf(remove.toUpperCase());
  4.         if (indexOf != -1){
  5.             if (!(startSubst == 0 && indexOf == 0)){
  6.                 result.append(base.substring(startSubst, startSubst+indexOf));
  7.             }
  8.             return withoutStringProblem(base, remove, result, startSubst+indexOf);
  9.         }
  10.         else{
  11.             result.append(base.substring(startSubst, base.length()));
  12.         }
  13.         return result.toString();
  14.     }
  15.     public String withoutString(String base, String remove) {
  16.         return withoutStringProblem(base, remove, new StringBuilder(), null);
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement