Trims off white space from the beginning of a string.

@param input
the string to be trimmed
@return the trimmed string
342860
public static String trimFront(String input) {
		int i = 0;
		while (i < input.length() && Character.isWhitespace(input.charAt(i)))
			i++;
		return input.substring(i);
	}
296115
public static Slice trim(Slice utf8)
    {
        int start = firstNonWhitespacePosition(utf8);
        int end = lastNonWhitespacePosition(utf8, start);
        return utf8.slice(start, end - start);
    }
1072092
public ProcessedOption searchAllOptions(String input) {
        if (input.startsWith("--")) {
            ProcessedOption currentOption = findLongOptionNoActivatorCheck(input.substring(2));
            if(currentOption == null && input.contains("="))
                currentOption = startWithLongOptionNoActivatorCheck(input.substring(2));
            if (currentOption != null)
                currentOption.setLongNameUsed(true);
            //need to handle spaces in option names
            else if(Parser.containsNonEscapedSpace(input)) {
                return searchAllOptions(Parser.switchSpacesToEscapedSpacesInWord(input));
            }

            return currentOption;
        }
        else if (input.startsWith("-")) {
            ProcessedOption currentOption = findOption(input.substring(1));
            if(currentOption == null)
                currentOption = startWithOption(input.substring(1));

            if (currentOption != null)
                currentOption.setLongNameUsed(false);

            return currentOption;
        }
        else {
            return null;
        }
    }
285166
public static String extractValue(String input) {
        int index = input.indexOf('=') + 1;
        if (0 == index || index >= input.length()) {
            return "";
        }
        return input.substring(index).trim();
    }
1252904
function(input) {
		var result = {};
		if ('selectionStart' in input) {
			result.start = input.selectionStart;
			result.length = input.selectionEnd - result.start;
		} else if (document.selection) {
			input.focus();
			var sel = document.selection.createRange();
			var selLen = document.selection.createRange().text.length;
			sel.moveStart('character', -input.value.length);
			result.start = sel.text.length - selLen;
			result.length = selLen;
		}
		return result;
	}
1084129
public static String trimLeadingWhitespace(final String str) {
    if (!StringUtils.hasLength(str)) {
      return str;
    }

    final StringBuilder sb = new StringBuilder(str);
    while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
      sb.deleteCharAt(0);
    }
    return sb.toString();
  }
885702
private String stripSuffix(final String input, final String searchString) {
        final String stripped = input.replace(searchString, "");
        return stripped.trim();
    }
1074914
private String truncateAt(final String input, final String searchString) {
        final int i = input.indexOf(searchString);
        if (i != -1) {
            return input.substring(0, i);
        }
        return input;
    }
1018722
public static String stripQuotes( String input ) {
      if( input.length() < 2 ){
         return input;
      }else if( input.startsWith( SINGLE_QUOTE ) && input.endsWith( SINGLE_QUOTE ) ){
         return input.substring( 1, input.length() - 1 );
      }else if( input.startsWith( DOUBLE_QUOTE ) && input.endsWith( DOUBLE_QUOTE ) ){
         return input.substring( 1, input.length() - 1 );
      }else{
         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()]);
    }
155226
public static String sanitize(final String input)
    {
        if ( input == null )
        {
            return "";
        }

        String s = "";

        for ( int i = 0; i < input.length(); i++ )
        {

            char c = input.charAt(i);

            if ( c == '*' )
            {
                // escape asterisk
                s += "\\2a";
            }
            else if ( c == '(' )
            {
                // escape left parenthesis
                s += "\\28";
            }
            else if ( c == ')' )
            {
                // escape right parenthesis
                s += "\\29";
            }
            else if ( c == '\\' )
            {
                // escape backslash
                s += "\\5c";
            }
            else if ( c == '\u0000' )
            {
                // escape NULL char
                s += "\\00";
            }
            else if ( c <= 0x7f )
            {
                // regular 1-byte UTF-8 char
                s += String.valueOf(c);
            }
            else if ( c >= 0x080 )
            {

                // higher-order 2, 3 and 4-byte UTF-8 chars

                try
                {
                    byte[] utf8bytes = String.valueOf(c).getBytes("UTF8");

                    for ( byte b : utf8bytes )
                    {
                        s += String.format("\\%02x", b);
                    }

                }
                catch ( UnsupportedEncodingException e )
                {
                    // ignore
                }
            }
        }

        return s;
    }
1347151
public static String trim(String string)
  {
    if(string == null) {
      return null;
    }
    int length = string.length();
    int beginIndex = 0;
    for(; beginIndex < length; ++beginIndex) {
      if(!Character.isWhitespace(string.charAt(beginIndex))) break;
    }
    int endIndex = length - 1;
    for(; endIndex >= 0; --endIndex) {
      if(!Character.isWhitespace(string.charAt(endIndex))) break;
    }
    return string.substring(beginIndex, endIndex + 1);
  }
105418
public static String nullifyBadInput(String input)
    {
        if (input != null)
        {
            if (input.matches(emptyRegex))
            {
                return null;
            }
            return input.trim();
        }
        return null;
    }
424445
function trimNumericField(input) {
		while (input.length > 1 && input.charAt(0) === '0') {
			input = input.substring(1);
		}

		return input;
	}
517501
public static String toPlain(String input) {
        Matcher matcher = SPACE_PATTERN.matcher(input);
        if (matcher.find()) {
            return matcher.replaceAll("");
        } else {
            return input;
        }
    }
1008817
public static String trimAllWhitespace(String str) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder sb = new StringBuilder(str);
        int index = 0;
        while (sb.length() > index) {
            if (Character.isWhitespace(sb.charAt(index))) {
                sb.deleteCharAt(index);
            }
            else {
                index++;
            }
        }
        return sb.toString();
    }
924481
public static int skipTrailingAsciiWhitespace(String input, int pos, int limit) {
    for (int i = limit - 1; i >= pos; i--) {
      switch (input.charAt(i)) {
        case '\t':
        case '\n':
        case '\f':
        case '\r':
        case ' ':
          continue;
        default:
          return i + 1;
      }
    }
    return pos;
  }