Trims whitespace or a set of characters from both ends of this string
@param array $chars optional
@return \static
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);
			
	}
767287
public function reset(?string $char = null): string
    {
        $this->initialize();
        return
            $this->sectionSeparator($char);
    }
775832
static function TrimLeft($string, $chars = null)
    {
        self::InitEncoding();
        if (!$chars)
            return ltrim($chars);

        return ltrim($string, $chars);
    }
47341
public static Characters of(String chars) {
        return StringUtils.isEmpty(chars) ? Characters.NONE : new Characters(false, chars.toCharArray());
    }
43540
public static function  trim($str,$charlist='')
    {
        if($charlist == '') return trim($str);

        return self::ltrim(self::rtrim($str));
    }
377901
protected static function rand($chars, $length)
    {
        $string = '';
        $max    = static::len($chars) - 1;
        $i      = 0;

        while ($i < $length)
        {
            $string .= $chars[Num::randomInt(0, $max)];
            $i++;
        }

        return $string;
    }
1221630
public static function truncate($text, $chars = 60) {
        if (!$text)
            return $text;
        
        $lines = explode("\n", $text);
        foreach ($lines as &$line)
            $line = trim($line);
        $text = implode(" ", $lines);
        if (strlen($text) <= $chars)
            return $text;
        
        $text = $text . " ";
        $text = substr($text, 0, $chars);
        $text = substr($text, 0, strrpos($text, ' '));
        $text = $text . "...";
        return $text;
    }
339803
public function setValidChars(string $chars): self
	{
		$this->assertCharacterClass($chars);

		$this->validChars = $chars;
		$this->setOptions['validChars'] = null;

		return $this;
	}
726812
public static String trimAllWhitespace(String str) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder buf = new StringBuilder(str);
        int index = 0;
        while (buf.length() > index) {
            if (Character.isWhitespace(buf.charAt(index))) {
                buf.deleteCharAt(index);
            } else {
                index++;
            }
        }
        return buf.toString();
    }
1185844
private static function trimEdge($string, $char)
    {
        if (substr($string, 0, 1) == $char) {
            $string = substr($string, 1, -1);
        }

        return $string;
    }
920067
public function scape_chars(array $chars = null)
    {
        if ($chars !== null) {
            $this->escapeChars = $chars;
            return $this;
        }
        return $this->escapeChars;
    }
675971
private static function isWhiteSpace($char)
    {
        return $char === self::CHAR_SPACE || $char === self::CHAR_CARRIAGERETURN || $char === self::CHAR_NEWLINE || $char === self::CHAR_TAB || $char === self::CHAR_VERTICALTAB;
    }
507426
public static CharPredicate among(final String chars) {
    return new CharPredicate() {
      @Override public boolean isChar(char c) {
        return chars.indexOf(c) >= 0;
      }
      @Override public String toString() {
        return '[' + chars + ']';
      }
    };
  }
786830
public static function trimStringArray(array $string, $recursion = true)
    {
        foreach ($string as $key => $value) {
            if (is_array($value) && $recursion) {
                $string[$key] = self::trimStringArray($value);
            } elseif (!is_array($value)) {
                $string[$key] = trim($value);
            }
        }

        return $string;
    }
232460
private function _trimSpecialsChars ($s)
    {
        if (count($this->getNotReplacedChars()) == 0) {
            $reg = '~[^-a-z0-9_]+~';
        } else {
            $reg = '~[^-a-z0-9_' . implode('',$this->getNotReplacedChars()) .']+~';
        }
        return preg_replace($reg, '', $s);
    }
1143539
private function trimSpecialsChars($s)
    {
        if (count($this->getNotReplacedChars()) == 0) {
            $reg = '~[^-a-z0-9_]+~';
        } else {
            $reg = '~[^-a-z0-9_' . implode('', $this->getNotReplacedChars()) .']+~';
        }
        return preg_replace($reg, '', $s);
    }
881810
public function trim($regex = Strings::TRIM_CHARACTERS)
    {
        $this->_string = Strings::trim($this->_string, $regex);
        $this->_direction = null;

        return $this;
    }