Find the next separator.

TODO: allow other separators, too?

@param str String
@param start Starting position
@return Next separator position, or end of string.
168191
private static int nextSep(String str, int start) {
    int next = str.indexOf(',', start);
    return next == -1 ? str.length() : next;
  }
999399
public static String[] split(String str, char separator) {
    final int len;
    if (str == null 
        || ((len = str.length()) == 0)) {
      return null;
    }

    List<String> componentList = new ArrayList<String>();
    int startIndex = 0;

    for (int i = 0; i < len; i++) {
      if (str.charAt(i) == separator) {
        componentList.add(str.substring(startIndex, i));
        startIndex = i + 1;
      }
    }

    if (str.charAt(len - 1) != separator) {
      componentList.add(str.substring(startIndex, len));
    }

    return componentList.toArray(new String[componentList.size()]);
  }
1069035
private int find(UTF8String str, int start) {
    assert (str.numBytes > 0);
    while (start <= numBytes - str.numBytes) {
      if (ByteArrayMethods.arrayEquals(base, offset + start, str.base, str.offset, str.numBytes)) {
        return start;
      }
      start += 1;
    }
    return -1;
  }
212654
public String substring(int start, int end) {

    return new String(this.buffer, this.initialOffset + start, end - start);
  }
737983
private int findNextParaPos(int startPara, String paraStr) {
    if (allParas == null || allParas.size() < 1) {
      return -1;
    }
    if (startPara >= allParas.size() || startPara < 0) {
      startPara = 0;
    }
    if (startPara + 1 < allParas.size() && paraStr.equals(allParas.get(startPara + 1))) {
      return startPara + 1;
    }
    if (paraStr.equals(allParas.get(startPara))) {
      return startPara;
    }
    if (startPara - 1 >= 0 && paraStr.equals(allParas.get(startPara - 1))) {
      return startPara - 1;
    }
    return -1;
  }
57167
def __find_args_separator(self, decl_string, start_pos):
        """"""
        bracket_depth = 0
        for index, ch in enumerate(decl_string[start_pos:]):
            if ch not in (self.__begin, self.__end, self.__separator):
                continue  # I am interested only in < and >
            elif self.__separator == ch:
                if not bracket_depth:
                    return index + start_pos
            elif self.__begin == ch:
                bracket_depth += 1
            elif not bracket_depth:
                return index + start_pos
            else:
                bracket_depth -= 1
        return -1
1251879
function (str, findChar, start) {
            var index = str.indexOf(findChar, start);
            while (index != -1) {
                if (!this.isEscaped(str, index)) {
                    return index;
                }
                // continue search after escaped character
                index = str.indexOf(findChar, index + 1);
            }
            return -1;
        }
1298913
@Override
  public int nextStartPosition() throws IOException {
    if (findMatches()) {
      currentMatch = queueMatches.get(0);
      queueMatches.remove(0);
      noMorePositions = false;
      return currentMatch.startPosition();
    } else {
      currentMatch = null;
      noMorePositions = true;
      return NO_MORE_POSITIONS;
    }
  }
383122
public String mkString(String start, String sep, String end) {
		StringBuilder ret = new StringBuilder(start);
		for (int i = 0; i < inner.size(); i++) {
			ret.append(inner.get(i));
			if (i != (inner.size() - 1)) {
				ret.append(sep);
			}
		}
		return ret.append(end).toString();
	}
278226
private int skipForward(char[] chars, int start, int length) {
    if (tc.isEntryEnabled())
      tc.entry(this,cclass, "skipForward", new Object[]{chars,new Integer(start),
        new Integer(length)});
    int ans = length;
    for (int i = 0; i < length; i++)
      if (chars[start+i] == MatchSpace.SUBTOPIC_SEPARATOR_CHAR) {
        ans = i;
        break;
      }
    if (tc.isEntryEnabled())
      tc.exit(this,cclass, "skipForward", new Integer(ans));
    return ans;
  }
1269915
def opt_separator(self) -> bool:
        
        start = self.offset
        self.dfa([
            {  # state 0: whitespace
                "": lambda: -1,
                " ": lambda: 0,
                "\t": lambda: 0,
                "\n": lambda: 0,
                "\r": lambda: 1,
                "/": lambda: 2
            },
            {  # state 1: CR/LF?
                "": self._back_break,
                "\n": lambda: 0
            },
            {  # state 2: start comment?
                "": self._back_break,
                "/": lambda: 3,
                "*": lambda: 4
            },
            {  # state 3: line comment
                "": lambda: 3,
                "\n": lambda: 0
            },
            {  # state 4: block comment
                "": lambda: 4,
                "*": lambda: 5
            },
            {  # state 5: end block comment?
                "": lambda: 4,
                "/": lambda: 0,
                "*": lambda: 5
            }])
        return start < self.offset
1173738
private static function substr($str, $start, $len)
    {
        if (function_exists('mb_substr'))
        {
            return mb_substr($str, $start, $len, 'UTF-8');
        }
        else
        {
            return substr($str, $start, $len * 2);
        }
    }
368781
public static String combine(String str1, String str2, String separator) {

        if (separator == null || separator.isEmpty()) {
            return str1 == null ? str2 : str1.concat(str2);
        }
        if (str1 == null)
            str1 = "";
        if (str2 == null)
            str2 = "";

        StringBuilder builder = new StringBuilder();
        if (str1.endsWith(separator)) {
            builder.append(str1.substring(0, str1.length() - separator.length()));
        } else {
            builder.append(str1);
        }
        builder.append(separator);

        if (str2.startsWith(separator)) {
            builder.append(str2.substring(separator.length()));
        } else {
            builder.append(str2);
        }

        return builder.toString();
    }
1328330
public static List<String> split(String s, String separator) {
        if (s == null) return null;
        List<String> rslt = null;
        if (s.isEmpty() || isEmpty(separator)) {
            rslt = new ArrayList<>(1);
            rslt.add(s);
            return rslt;
        }

        //return s.split(COMMA_SPLIT); - NOT WORKING when compiled to JS

        int start = 0;
        int p = start;
        do {
            int j = s.indexOf(separator, p);
            if (j == -1) {
                if (rslt == null) {
                    rslt = new ArrayList<>(1);
                    rslt.add(s);
                    return rslt;
                }
                rslt.add(s.substring(start));
                break;
            }
            if (j > 0 && s.charAt(j - 1) == '\\') {
                p = j + 1;
                continue;
            } else {
                if (rslt == null) rslt = new ArrayList<String>();
                rslt.add(s.substring(start, j));
                start = j + 1;
                p = start;
            }

        } while (true);

        return rslt;
    }
1081348
public static List<String> split(String str, char sepChr) {
    	List<String> result = new ArrayList<String>();
    	int idx = 0;
    	while(true) {
    		int idx2 = str.indexOf(sepChr, idx);
    		if(idx2 < 0) {
    			result.add(str.substring(idx));
    			break;
    		}
    		result.add(str.substring(idx, idx2));
    		idx = idx2 + 1;
    	}
        return result;
    }
270551
function( str ){
      var first, last;

      // find first non-space char
      for( first = 0; first < str.length && str[first] === ' '; first++ ){}

      // find last non-space char
      for( last = str.length - 1; last > first && str[last] === ' '; last-- ){}

      return str.substring(first, last + 1);
    }
1189777
public static String[] split(String str, String separator, boolean trim) {
        if (str == null) {
            return null;
        }

        char sep = separator.charAt(0);

        ArrayList<String> strList = new ArrayList<String>();
        StringBuilder split = new StringBuilder();
        int index = 0;
        while ((index = StringUtils.findNext(str, sep, StringUtils.ESCAPE_CHAR, index, split)) >= 0) {
            ++index; // move over the separator for next search
            strList.add(split.toString());
            split.setLength(0); // reset the buffer
        }

        strList.add(split.toString());
        // remove trailing empty split(s)
        if (trim) {
            int last = strList.size(); // last split
            while (--last>=0 && "".equals(strList.get(last))) {
                strList.remove(last);
            }
        }

        return strList.toArray(new String[strList.size()]);
    }