Java String Index Of getReplaceIndexes(String input, int startIndex, Stack replaceStack)

Here you can find the source of getReplaceIndexes(String input, int startIndex, Stack replaceStack)

Description

get Replace Indexes

License

Open Source License

Declaration

private static void getReplaceIndexes(String input, int startIndex, Stack<Integer> replaceStack) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    private static void getReplaceIndexes(String input, int startIndex, Stack<Integer> replaceStack) {

        int idx = startIndex + 3;
        Stack<Character> stack = new Stack<>();

        while (idx < input.length()) {
            switch (input.charAt(idx)) {
            case ')':
                if (stack.isEmpty()) {
                    idx = input.length();
                } else {
                    stack.pop();//from  w w  w .  java 2 s  . c o  m
                }
                break;
            case '(':
                stack.push('(');
                break;
            case '*':
            case '+':
                replaceStack.push(idx);
                break;
            case '|':
                if (stack.isEmpty()) {
                    idx = input.length();
                }
                break;
            }

            idx += 1;
        }
    }
}

Related

  1. getMatchingIndexes(final String source, final String match)
  2. getMergedLine(String lineOne, String lineTwo, int insertingIndex)
  3. getNewlineIndexes(String src)
  4. getOffspringStrings(int startIndex, String treeStr)
  5. getPDFEncodingIndex(String key)
  6. getStructValue(String struct, int index)
  7. getTabIndexes(String text)
  8. getUserGroupsFromImpex( final String impexContent, final int uidIndex)
  9. indexOf(final String str, final String searchString)