Trims leading chars.
@param string $string
@param string $chars
@return string The trimmed string
775832
static function TrimLeft($string, $chars = null)
    {
        self::InitEncoding();
        if (!$chars)
            return ltrim($chars);

        return ltrim($string, $chars);
    }
1347637
public static function trim($string, $side = self::TRIM_BOTH, $chars = null)
    {
        if ($side == self::TRIM_START) {
            return ltrim($string, $chars);
        } elseif ($side == self::TRIM_END) {
            return rtrim($string, $chars);
        } elseif ($side == self::TRIM_BOTH) {
            return trim($string, $chars);
        }
    }
342855
public function trimRight($charlist = null)
    {
        return $this->cloneInstance(
            function (StringObject $new) use ($charlist) {
                $new->string = Mbstring::rtrim($new->string, $charlist);
            }
        );
    }
57968
public String trimLeading(String str) {
        if (str == null) {
            return null;
        }

        int length = str.length();
        for (int i=0; i<length; i++) {
            if (str.charAt(i) > ' ') {
                return str.substring(i);
            }
        }

        return "";
    }
378600
public static String 
    trimRight( String string ) 
    {
    	for( int i = string.length(); i > 0; --i )
    	{
    		if( string.charAt(i-1) != ' '
    		&& string.charAt(i-1) != '\t'
    		&& string.charAt(i-1) != '\n'
    		&& string.charAt(i-1) != '\r' ) 
    		{    			
    			return i == string.length() ? string : 
    			                              string.substring( 0, i );
    		}
    	}
    	return "";
    }
100416
private String trim(String string) {

		while (string.startsWith("\"") && string.endsWith("\"")) {

			string = string.substring(1, string.length() - 1);
		}
		return string;
	}
792709
protected String trim(String s) {
        if (s == null || s.length() == 0)
            return s;

        return s.trim();
    }
706930
public static function shortenAndCapitalize($string)
    {
        $result = '';
        $parts = explode(' ', trim($string));

        foreach ($parts as $part) {
            $result = $result.strtoupper(mb_substr($part, 0, 1));
        }

        return $result;
    }
920067
public function scape_chars(array $chars = null)
    {
        if ($chars !== null) {
            $this->escapeChars = $chars;
            return $this;
        }
        return $this->escapeChars;
    }
734564
public static String trimLeadingCharacter(final String str, final char leadingCharacter) {
    if (!StringUtils.hasLength(str)) {
      return str;
    }

    final StringBuilder sb = new StringBuilder(str);
    while (sb.length() > 0 && sb.charAt(0) == leadingCharacter) {
      sb.deleteCharAt(0);
    }
    return sb.toString();
  }
1255521
public function trimStart(array $chars = null){
		
		if($chars === null){
			return new static(\ltrim($this->_Value), $this->_Encoding);
		}
		
		$chars = \preg_quote(\implode(static::NONE, $chars));
		
		$str = \preg_replace(
				\sprintf('/^[%s]+/us', $chars),
				static::NONE,
				$this->_Value);
		
		return new static($str, $this->_Encoding);
		
	}
1032191
public function trim($char = null)
    {
        if ($this->isNull($char)) {
            $value = trim($this->val());
        } else {
            if (!$this->isString($char)) {
                throw new StringObjectException(StringObjectException::MSG_INVALID_ARG, [
                    '$char',
                    'string'
                ]);
            }

            $value = trim($this->val(), $char);
        }

        $this->val($value);

        return $this;
    }
1330258
public final String trimFrom(String s) {
    int first;
    int last;

    // removes leading matches
    for (first = 0; first < s.length(); ) {
      final int codePoint = s.codePointAt(first);
      if (!matches(codePoint)) {
        break;
      }
      first += Character.charCount(codePoint);
    }

    //remove trailing matches
    for (last = s.length() - 1; last >= first; --last) {
      if (Character.isLowSurrogate(s.charAt(last))) {
        --last;
      }
      if (!matches(s.codePointAt(last))) {
        break;
      }
    }

    return s.substring(first, last + 1);
  }
496285
public function trim(array $chars = null){
		
		if($chars === null){
			return new static(\trim($this->_Value), $this->_Encoding);
		}
	
		$chars = \preg_quote(\implode(static::NONE, $chars));
		
		$str = \preg_replace(
				\sprintf('/(^[%s]+)|([%s]+$)/us', $chars, $chars),
				static::NONE,
				$this->_Value);
		
		return new static($str, $this->_Encoding);
			
	}
1165624
public function trim($charlist = null, $ends = null)
    {
        switch (true) {
            case is_null($charlist) && ($ends == self::BOTH || is_null($ends)):
                $this->setInternalValue(trim($this->getInternalValue()));
                break;

            case is_null($ends) || $ends == self::BOTH:
                $this->setInternalValue(trim($this->getInternalValue(), $charlist));
                break;

            case !is_null($ends):
                switch (true) {
                    case $ends == self::LEFT:
                        $callback = 'ltrim';
                        break;

                    case $ends == self::RIGHT:
                        $callback = 'rtrim';
                        break;
                }

                if (is_null($charlist)) {
                    $this->setInternalValue(call_user_func($callback, $this->getInternalValue()));
                } else {
                    $this->setInternalValue(call_user_func($callback, $this->getInternalValue(), $charlist));
                }

                break;

        }

        return $this;

    }
1274932
public static String removeStartingChars(String s, char c) {
        int lastToRemove = -1;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == c) {
                lastToRemove = i;
                continue;
            }

            if (s.charAt(i) != c) {
                break;
            }
        }

        if (lastToRemove < 0) return s;
        return s.substring(lastToRemove + 1);
    }
1083160
public function trimRight( $string, $needle, $caseSensitive = true )
	{
		$strPos = $caseSensitive ? "strpos" : "stripos";
		if( $strPos( $string, $needle, strlen( $string ) - strlen( $needle )) !== false ) {
			$string = substr( $string, 0, -strlen( $needle ));
		}
		return $string;
	}