Android String Search findLastNotOf(String str, String chars)

Here you can find the source of findLastNotOf(String str, String chars)

Description

find Last Not Of

License

Open Source License

Declaration

public final static int findLastNotOf(String str, String chars) 

Method Source Code

//package com.java2s;

public class Main {
    public final static int findLastNotOf(String str, String chars) {
        return findOf(str, chars, (str.length() - 1), 0, -1, false);
    }//from w  ww  . jav a  2 s . c o  m

    public final static int findOf(String str, String chars, int startIdx,
            int endIdx, int offset, boolean isEqual) {
        if (offset == 0)
            return -1;
        int charCnt = chars.length();
        int idx = startIdx;
        while (true) {
            if (0 < offset) {
                if (endIdx < idx)
                    break;
            } else {
                if (idx < endIdx)
                    break;
            }
            char strc = str.charAt(idx);
            int noEqualCnt = 0;
            for (int n = 0; n < charCnt; n++) {
                char charc = chars.charAt(n);
                if (isEqual == true) {
                    if (strc == charc)
                        return idx;
                } else {
                    if (strc != charc)
                        noEqualCnt++;
                    if (noEqualCnt == charCnt)
                        return idx;
                }
            }
            idx += offset;
        }
        return -1;
    }
}

Related

  1. indexOf(String str, String searchStr)
  2. skipSpaces(String s, int start)
  3. nestedIndexOf(final String s, final int startPos, final String open, final String close)
  4. findFirstNotOf(String str, String chars)
  5. findFirstOf(String str, String chars)
  6. findLastOf(String str, String chars)
  7. firstCharUpper(String myString)
  8. lastIndexNotOf(String str, String chars, int fromIndex)