Splits the options string at every unescaped input delimiter, i.e., every unescaped "|".
@param input the options string
@return the array with the various options
165486
public static String[] splitOptions(String input) {

        //Note that we use a regex matching all "|" characters not prefixed by "\"

        //Since we define a regex for matching, the input delimiter "|" needs to be escaped, as well as "\",
        //which is even double-escaped - one escaping is due to the String, one due to the regex.

        // emulate missing lookbehinds in JS regexes by first reversing the input,
        // then using a split with lookaheads, and finally reversing the parts resulting
        // from the split
        String reverse = reverse(input);
        String[] parts = reverse.split("\\|(?!\\\\)");
        String[] finalParts = new String[parts.length];
        int lastIndex = parts.length - 1;
        for (int i = 0; i < parts.length; i++) {
            finalParts[lastIndex - i] = reverse(parts[i]);
        }
        return finalParts;

    }
311099
public static String[] extractList(String input, char delimiter) {
        int end = input.indexOf(delimiter);
        if (-1 == end) {
            return new String[] { input.trim() };
        }
        List<String> output = new LinkedList<String>();
        int start = 0;
        do {
            output.add(input.substring(start, end).trim());
            start = end + 1;
            end = input.indexOf(delimiter, start);
        } while (-1 != end);
        // copy the last value if it exists
        if (start < input.length()) {
            output.add(input.substring(start).trim());
        }
        return output.toArray(new String[output.size()]);
    }
476030
public static List<String> split(String input) {
        List<String> result = new ArrayList<>();
        StringBuilder cur = new StringBuilder();
        State state = State.START_FIELD;

        for (int i = 0; i < input.length(); i++) {
            char ch = input.charAt(i);
            switch (ch) {
                case ',':
                    switch (state) {
                        case IN_QFIELD:
                            cur.append(',');
                            break;
                        default:
                            result.add(cur.toString());
                            cur.setLength(0);
                            state = State.START_FIELD;
                            break;
                    }
                    break;
                case '"':
                    switch (state) {
                        case START_FIELD:
                            state = State.IN_QFIELD;
                            break;
                        case IN_QFIELD:
                            state = State.END_QFIELD;
                            break;
                        case IN_FIELD:
                            throw new CSVParseException("unexpected quote", input, i);
                        case END_QFIELD:
                            cur.append('"');
                            state = State.IN_QFIELD;
                            break;
                    }
                    break;
                default:
                    switch (state) {
                        case START_FIELD:
                            state = State.IN_FIELD;
                            break;
                        case IN_FIELD:
                        case IN_QFIELD:
                            break;
                        case END_QFIELD:
                            throw new CSVParseException("extra character after quoted string",
                                                        input, i);
                    }
                    cur.append(ch);
                    break;
            }
        }

        if (state == State.IN_QFIELD) {
            throw new CSVParseException("unclosed quote", input, input.length());
        }

        result.add(cur.toString());
        return result;
    }
602269
public static char[] replace(final char[] input)
	{

		int surLow = 0xD800;
		int surHgh = 0xDFFF;

		int end = input.length;
		char[] output = new char[end];

		for (int i = 0; i < end; i++) {
			if ((int) input[i] >= surLow && input[i] <= surHgh) {
				output[i] = '?';
			}
			else {
				output[i] = input[i];
			}
		}

		return output;
	}
11048
public static String[] splitAsArray(String source, char delimiter) {

        List<String> result = splitAsList(source, delimiter);
        return result.toArray(new String[result.size()]);
    }
105833
protected static String toLowerCase(String input) {
        if(Character.isUpperCase(input.charAt(0)))
            return input.substring(0, 1).toLowerCase() + input.substring(1);
        return input;
    }
1216944
public static String getPrefix(String input, char delimiter) {
        int index = input.indexOf(delimiter);
        if (index > -1) {
            return input.substring(0, index);
        }

        return input;
    }
543210
private static String[] split(String input) {
        char macroStart = MACRO_START.charAt(0);
        char macroEnd = MACRO_END.charAt(0);

        int startIndex = 0;
        boolean inMacro = false;

        List<String> list = new ArrayList<String>();

        for (int endIndex = 0; endIndex < input.length(); endIndex++) {
            char chr = input.charAt(endIndex);

            if (!inMacro) {
                if (chr == macroStart) {
                    String result = input.substring(startIndex, endIndex);
                    if (result.length() > 0) {
                        list.add(result);
                    }
                    inMacro = true;
                    startIndex = endIndex;
                }
            } else {
                if (chr == macroEnd) {
                    String result = input.substring(startIndex, endIndex + 1);
                    if (result.length() > 0) {
                        list.add(result);
                    }
                    inMacro = false;
                    startIndex = endIndex + 1;
                }
            }
        }

        String result = input.substring(startIndex);
        if (result.length() > 0) {
            list.add(result);
        }

        return list.toArray(new String[list.size()]);
    }
703009
public static String decode(final String input) {
		return new String(decode(input.getBytes(charsetISOLatin1)), charsetUTF8);
	}
1269366
public static char[] asCharacterTypeArray(List<Character> input) {
		char[] result = new char[input.size()];

		for (int i = 0; i < result.length; i++) {
			result[i] = input.get(i);
		}

		return result;
	}
717958
public static String underscored(final String input) {
        if (input == null || input.length() == 0) {
            return "";
        }

        return input.trim().replaceAll("([a-z\\d])([A-Z]+)", "$1_$2").replaceAll("[-\\s]+", "_").toLowerCase();
    }
1149028
public static double[] uncompressDoubleArray(byte[] input)
            throws IOException
    {
        int uncompressedLength = Snappy.uncompressedLength(input, 0, input.length);
        double[] result = new double[uncompressedLength / 8];
        impl.rawUncompress(input, 0, input.length, result, 0);
        return result;
    }
217605
public List<Object> parse(final String input, final List<String> operators) {
		final List<Object> result = new ArrayList<Object>();
		if (operators.size() != 0) {
			final boolean innerLoop = operators.size() == 1;
			final MiniParser currentParser = innerLoop ? INNER_MINI_PARSER
					: MINI_PARSER;
			final String operator = operators.get(0);
			final List<String> segments;
			if (operator.length() == 1) {
				segments = currentParser.split(input, operator.charAt(0));
			} else if (operator.length() == 2) {

				List<String> allSegments = currentParser.scan(input, String
						.valueOf(operator.charAt(0)), String.valueOf(operator
						.charAt(1)), true);
				if (allSegments.size() > 0) {
					// the first part is not processed any further
					result.add(allSegments.get(0));
				}
				if (allSegments.size() > 1) {
					segments = allSegments.subList(1, allSegments.size());
				} else {
					segments = Collections.emptyList();
				}

			} else {
				throw new IllegalArgumentException(
						"Operators must either be start/end pairs or single characters");

			}
			if (innerLoop) {
				result.addAll(segments);
			} else {
				for (String segment : segments) {
					List<Object> parse = parse(segment, operators.subList(1,
							operators.size()));
					if (parse.size() == 1 && parse.get(0) instanceof String) {
						result.add(parse.get(0));
					} else {
						result.add(parse);
					}
				}
			}
		}
		return result;
	}
342860
public static String trimFront(String input) {
		int i = 0;
		while (i < input.length() && Character.isWhitespace(input.charAt(i)))
			i++;
		return input.substring(i);
	}
221639
public static List<Token> tokenize(final String input) {
        List<Token> result = new ArrayList<Token>();
        if (input == null) {
            return result;
        }

        final int WHITESPACE = 0;
        final int WORD = 1;
        final int STRINGDQ = 2;
        final int STRINGSQ = 3;
        final int COMMENT = 4;

        int state = WHITESPACE;
        char ch; // character in hand
        int tokenIndex = -1;
        StringBuilder token = new StringBuilder("");

        for (int i = 0; i < input.length(); i++) {
            ch = input.charAt(i);
            switch (state) {
                case WHITESPACE:
                    if (Character.isWhitespace(ch)) {
                        // keep state
                    } else if (Character.isLetterOrDigit(ch) || ch == '_') {
                        state = WORD;
                        tokenIndex = i;
                        token.append(ch);
                    } else if (ch == '"') {
                        state = STRINGDQ;
                        tokenIndex = i;
                    } else if (ch == '\'') {
                        state = STRINGSQ;
                        tokenIndex = i;
                    } else if (ch == '#') {
                        state = COMMENT;
                    } else {
                        state = WORD;
                        tokenIndex = i;
                        token.append(ch);
                    }
                    break;

                case WORD:
                    if (Character.isWhitespace(ch)) {
                        // submit token
                        result.add(new Token(tokenIndex, token.toString()));
                        token.setLength(0);
                        state = WHITESPACE;
                    } else if (Character.isLetterOrDigit(ch) || ch == '_') {
                        token.append(ch); // and keep state
                    } else if (ch == '"') {
                        if (i < input.length()-1 && input.charAt(i+1) == '"' ) {
                            // Yes, it's somewhat wrong in terms of statemachine, but it's the
                            // simplest and crearest way.
                            token.append('"');
                            i++;
                            // and keep state.
                        } else {
                            state = STRINGDQ; // but don't append; a"b"c is the same as abc.
                        }
                    } else if (ch == '\'') {
                        if (i < input.length()-1 && input.charAt(i+1) == '\'' ) {
                            // Yes, it's somewhat wrong in terms of statemachine, but it's the
                            // simplest and crearest way.
                            token.append('\'');
                            i++;
                            // and keep state.
                        } else {
                            state = STRINGSQ; // but don't append; a"b"c is the same as abc.
                        }
                    } else if (ch == '#') {
                        // submit token
                        result.add(new Token(tokenIndex, token.toString()));
                        token.setLength(0);
                        state = COMMENT;
                    } else {
                        // for now we do allow special chars in words
                        token.append(ch);
                    }
                    break;

                case STRINGDQ:
                    if (ch == '"') {
                        if (i < input.length() - 1 && input.charAt(i+1) == '"') {
                            token.append('"');
                            i++;
                            // and keep state
                        } else {
                            state = WORD;
                        }
                    } else {
                        token.append(ch);
                    }
                    break;

                case STRINGSQ:
                    if (ch == '\'') {
                        if (i < input.length() - 1 && input.charAt(i+1) == '\'') {
                            token.append('\'');
                            i++;
                            // and keep state
                        } else {
                            state = WORD;
                        }
                    } else {
                        token.append(ch);
                    }
                    break;

                case COMMENT:
                    // eat ch
                    break;

                default:
                    assert false : "Unknown state in Shell.tokenize() state machine";
                    break;
            }
        }

        if (state == WORD || state == STRINGDQ || state == STRINGSQ) {
            result.add(new Token(tokenIndex, token.toString()));
        }

        return result;
    }
42513
public static String[] splitByComma(String input, boolean allowEmpty) {
        if (input == null) {
            return null;
        }
        String[] splitWithEmptyValues = trim(input).split("\\s*,\\s*", -1);
        return allowEmpty ? splitWithEmptyValues : subtraction(splitWithEmptyValues, new String[]{""});
    }
619489
private static String transformWARCDate(final String input) {
		
		StringBuilder output = new StringBuilder(14);
		
		output.append(input.substring(0,4));
		output.append(input.substring(5,7));
		output.append(input.substring(8,10));
		output.append(input.substring(11,13));
		output.append(input.substring(14,16));
		output.append(input.substring(17,19));
		
		return output.toString();
	}