Android StringBuilder Remove deleteAllIn(StringBuilder sb, String startStr, String endStr)

Here you can find the source of deleteAllIn(StringBuilder sb, String startStr, String endStr)

Description

delete All In

License

Apache License

Declaration

public static void deleteAllIn(StringBuilder sb, String startStr,
        String endStr) 

Method Source Code

//package com.java2s;
/*//from  ww  w . j a v  a 2s .  co  m
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Auther:yinglovezhuzhu@gmail.com
 * File: StringUtil.java
 * Date:2014?1?2?
 * Version:v1.0
 */

public class Main {

    public static void deleteAllIn(StringBuilder sb, String startStr,
            String endStr) {
        int startIndex = 0;
        int endIndex = 0;
        while ((startIndex = sb.indexOf(startStr)) >= 0
                && (endIndex = sb.indexOf(endStr)) >= 0) {
            sb.delete(startIndex, endIndex + endStr.length());
        }
    }
}

Related

  1. removeAll(final StringBuilder s, final Pattern start, final Pattern end)
  2. deleteAllIn(StringBuilder sb, String startStr, String endStr)
  3. remove(final StringBuilder s, final Pattern start, final Pattern end, final boolean includeEnd)