Java Utililty Methods String Remove

List of utility methods to do String Remove

Description

The list of methods to do String Remove are organized into topic(s).

Method

IteratorgetAndRemove(String key)
get And Remove
Iterator<String[]> iter = iteratorMap.get(key);
remove(key);
return iter;
StringparseAndRemoveDuplicates(String s, String del)
parse And Remove Duplicates
if (s == null)
    return s;
Set<String> set = parseAndRemoveDuplicatesAsSet(s, del);
return getSeparatedListOfString(set, "", "", false, del);
StringremoveAll(String origStr, String removeStr)
Remove all the ocurrences of a substring from a string
return replaceAll(origStr, removeStr, "");
StringremoveAll(String targetStr, String removeStr)
remove All
if (targetStr == null) {
    throw new IllegalArgumentException("'targetStr' is null");
if (removeStr == null) {
    throw new IllegalArgumentException("'start' is null");
return removeAll(targetStr, new String[] { removeStr });
StringremoveAndConcatenateAlternate(String s1, String s2)
remove And Concatenate Alternate
String s3 = s1.concat(s2);
Map<Character, List<Integer>> tracker = new HashMap<>();
for (int i = 0; i < s3.length(); i++) {
    char c = s3.charAt(i);
    if (tracker.containsKey(c)) {
        tracker.get(c).add(i);
    } else {
        List<Integer> indexes = new ArrayList<>();
...
StringremoveBlankLines(String s)
remove Blank Lines
String[] lines = split(s, CRLF);
boolean lastLineBlank = false;
String newS = "";
for (int i = 0; i < lines.length; i++) {
    if (!lines[i].equals("")) {
        newS += lines[i] + CRLF;
        lastLineBlank = false;
    } else {
...
StringremoveCommandFromString(String commandString)
remove Command From String
String result = new String();
String[] split = commandString.split(" ");
List<String> wordList = new ArrayList(Arrays.asList(split));
wordList.remove(0);
for (String word : wordList) {
    result += word + " ";
return result;
...
String[]removeEmpties(final String... values)
Create an array with only the non-null and non-empty values
if (values == null || values.length == 0)
    return new String[0];
List<String> validValues = new ArrayList<String>();
for (String value : values)
    if (value != null && value.length() > 0)
        validValues.add(value);
return validValues.toArray(new String[validValues.size()]);
StringremoveEscape(String s_)
remove Escape
if (s_ == null)
    return null;
StringBuffer sb_ = new StringBuffer();
int i = 0;
while (true) {
    int j = s_.indexOf('\\', i);
    if (j >= 0) {
        sb_.append(s_.substring(i, j));
...
char[]removeExtraSpacesAndSpecialCharacters(String toSearch, boolean setAllToLowerCase)
remove Extra Spaces And Special Characters
boolean lastCharacterAddedWasWhiteSpace = false;
StringBuilder searchString = new StringBuilder();
for (int index = 0; index < toSearch.length(); index++) {
    char currChar = toSearch.charAt(index);
    if (setAllToLowerCase) {
        currChar = Character.toLowerCase(currChar);
    if (currChar != '\r' && currChar != '\n') {
...