left trim string

@param string $str
@param array $charlist
@return string
510846
public function ltrim($str, $charlist = null)
    {
        return isset($charlist) ? ltrim($str, $charlist) : ltrim($str);
    }
596457
public function ltrim(string $charlist = " \t\n\r\0\x0B"): self
    {
        return self::make(ltrim($this->text, $charlist));
    }
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();
    }
715047
public static function ltrim(string $s, string $charList = self::TRIM_CHARACTERS): string
    {
        $charList = \preg_quote($charList, '#');

        return static::replace($s, '#^[' . $charList . ']+#u', '');
    }
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()]);
    }
1362853
function trim(str, targetStr) {
    var retStr = "";
    var regStr;

    if (typeof str != "string") {
        return retStr;
    }

    if (typeof targetStr != "string" || !targetStr) {
        targetStr = "\\s";
    }

    regStr = "^" + targetStr + "*(.*?)" + targetStr + "*$";
    regStr = new RegExp(regStr);

    str = str.replace(regStr, "$1");
    return str;
}
336227
public static function trim(&$str='') {
		if (\is_array($str)) {
			foreach ($str as $k=>$v) {
				static::trim($str[$k]);
			}
		}
		else {
			cast::string($str, true);
			$str = \preg_replace('/(^\s+|\s+$)/u', '', $str);
		}
	}
175587
public static function truncateWords($str, $length, $trailing='...') {
		$words = explode(' ', $str);
		$cutwords = array_slice($words, 0, $length);

		return implode(' ', $cutwords).(count($words) > count($cutwords) ? $trailing:'');
	}
755740
public static function stripControlChars( $str ) {

		if( is_array($str) ) {
			foreach( $str as &$item ) {
				$item = static::stripControlChars($item);
			}
			return $str;
		}

		do {
			// 00-08, 11, 12, 14-31, 127
			$str = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/Su', '', $str, -1, $count);
		}
		while ($count);

		return $str;

	}
556696
public static function java_truncate(string $str): string
    {
        if (strlen($str) > 955) {
            return substr($str, 0, 475).'[...]'.substr($str, -475);
        }

        return $str;
    }
248190
protected function trimUnicode($value, $charList = '\\\\s')
    {
        $chars = preg_replace(
            ['/[\^\-\]\\\]/S', '/\\\{4}/S', '/\//'],
            ['\\\\\\0', '\\', '\/' ],
            $charList
        );

        $pattern = '^[' . $chars . ']*|[' . $chars . ']*$';
        return preg_replace("/$pattern/sSD", '', $value);
    }
1279230
public static function makeHTMLString($str)
    {

        $str = trim($str);
        $str = htmlspecialchars($str, ENT_COMPAT, 'utf-8');

        return nl2br($str);
    }
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();
  }
513665
public static function trim(string $s, string $charList = self::TRIM_CHARACTERS): string
    {
        $charList = \preg_quote($charList, '#');

        return static::replace($s, '#^[' . $charList . ']+|[' . $charList . ']+\z#u', '');
    }
1351415
public function trim($string, $charlist = null)
    {
        $string = (string)$string;

        if ($charlist === null) {
            return trim($string);
        } else {
            return trim($string, $charlist);
        }
    }
208706
public static function whitespace_multiline($str='', int $newlines=1) {
		ref\sanitize::whitespace_multiline($str, $newlines);
		return $str;
	}
586772
static function TrimRight($string, $chars = null)
    {
        self::InitEncoding();
        if (!$chars)
            return rtrim($chars);

        return rtrim($string, $chars);
    }