Strips whitespace.

@param  string $s UTF-8 encoding
@param  string $charList

@return string
@throws RegexpException
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', '');
    }
995378
def spaces_before_first_char(s)
		case s.md_type
		when :ulist
			i=0;
			# skip whitespace if present
			while s[i,1] =~ /\s/; i+=1 end
			# skip indicator (+, -, *)
			i+=1
			# skip optional whitespace
			while s[i,1] =~ /\s/; i+=1 end
			return i
		when :olist
			i=0;
			# skip whitespace
			while s[i,1] =~ /\s/; i+=1 end
			# skip digits
			while s[i,1] =~ /\d/; i+=1 end
			# skip dot
			i+=1
			# skip whitespace
			while s[i,1] =~ /\s/; i+=1 end
			return i
		else
			tell_user "BUG (my bad): '#{s}' is not a list"
			0
		end
	end
1351415
public function trim($string, $charlist = null)
    {
        $string = (string)$string;

        if ($charlist === null) {
            return trim($string);
        } else {
            return trim($string, $charlist);
        }
    }
949679
private StringBuilder stripWhitespace(String description) {
        // since we don't have a method that deletes characters (why?!!)
        // create a new StringBuffer to copy the text into
        StringBuilder result = new StringBuilder();
        int descriptionLength = description.length();

        // iterate through the characters...
        int start = 0;
        while (start < descriptionLength) {
            // seek to the first non-whitespace character...
            while (start < descriptionLength
                   && PatternProps.isWhiteSpace(description.charAt(start)))
            {
                ++start;
            }

            //if the first non-whitespace character is semicolon, skip it and continue
            if (start < descriptionLength && description.charAt(start) == ';') {
                start += 1;
                continue;
            }

            // locate the next semicolon in the text and copy the text from
            // our current position up to that semicolon into the result
            int p = description.indexOf(';', start);
            if (p == -1) {
                // or if we don't find a semicolon, just copy the rest of
                // the string into the result
                result.append(description.substring(start));
                break;
            }
            else if (p < descriptionLength) {
                result.append(description.substring(start, p + 1));
                start = p + 1;
            }
            else {
                // when we get here, we've seeked off the end of the string, and
                // we terminate the loop (we continue until *start* is -1 rather
                // than until *p* is -1, because otherwise we'd miss the last
                // rule in the description)
                break;
            }
        }
        return result;
    }
953375
protected function stripWhitespaces($str) {
       switch($this->stripWhitespaceMode) {
           case self::STRIP_WHITESPACE_AUTO:
               if(Helper::countSubString($str, '　') > self::STRIP_WHITESPACE_AUTO_NB_SPACES) {
                   break;
               }
           case self::STRIP_WHITESPACE_ALL:
               $str = preg_replace('/\x{3000}|\s/u', '', $str);
               break;
       }

       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);
    }
437562
public static void normalizeAndCollapseWhitespace(final StringBuilder strBuffer) {
        WhiteSpaceState currentState = WhiteSpaceState.WORD;
        for (int i = strBuffer.length() - 1; i >= 0; i--) {
            final char currentChar = strBuffer.charAt(i);
            if (Character.isWhitespace(currentChar)) {
                if (currentState == WhiteSpaceState.SPACE) {
                    strBuffer.delete(i, i + 1);
                } else if (currentChar != ' ') {
                    strBuffer.replace(i, i + 1, " ");
                }
                currentState = WhiteSpaceState.SPACE;
            } else {
                currentState = WhiteSpaceState.WORD;
            }
        }
    }
529502
public static function whitespace($str='', int $newlines=0) {
		ref\sanitize::whitespace($str, $newlines);
		return $str;
	}
738079
def _is_whitespace(self, char):
        """"""
        # \t, \n, and \r are technically contorl characters but we treat them
        # as whitespace since they are generally considered as such.
        if char in [' ', '\t', '\n', '\r']:
            return True
        cat = unicodedata.category(char)
        if cat == 'Zs':
            return True
        return False
487473
public static function ParseHttpAcceptLang ($languagesList) {
		$languages = [];
		$languageRanges = explode(',', trim($languagesList));
		foreach ($languageRanges as $languageRange) {
			$regExpResult = preg_match(
				"/(\*|[a-zA-Z0-9]{1,8}(?:-[a-zA-Z0-9]{1,8})*)(?:\s*;\s*q\s*=\s*(0(?:\.\d{0,3})|1(?:\.0{0,3})))?/",
				trim($languageRange),
				$match
			);
			if ($regExpResult) {
				$priority = isset($match[2])
					? (string) floatval($match[2])
					: '1.0';
				if (!isset($languages[$priority])) $languages[$priority] = [];
				$langOrLangWithLocale = str_replace('-', '_', $match[1]);
				$delimiterPos = strpos($langOrLangWithLocale, '_');
				if ($delimiterPos !== FALSE) {
					$languages[$priority][] = [
						strtolower(substr($langOrLangWithLocale, 0, $delimiterPos)),
						strtoupper(substr($langOrLangWithLocale, $delimiterPos + 1))
					];
				} else {
					$languages[$priority][] = [
						strtolower($langOrLangWithLocale),
						NULL
					];
				}
			}
		}
		krsort($languages);
		reset($languages);
		return $languages;
	}
228920
public function stripTags($whiteList = '')
    {
        if (!$this->isString($whiteList)) {
            throw new StringObjectException(StringObjectException::MSG_INVALID_ARG, [
                '$whiteList',
                'integer'
            ]);
        }

        $this->val(strip_tags($this->val(), $whiteList));

        return $this;
    }
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;

    }
1163088
public static function trim($string, $charlist = '\s\xA0')
    {
        $string = str_replace('&nbsp;', ' ', $string);

        return trim(preg_replace('@^[' . $charlist . ']+(.*)[' . $charlist . ']+$@u', '\\1', $string));
    }
1320756
public static String cleanup(String sequence) {
    String result = sequence.replaceAll("\\s", ""); // remove all white
    // space
    if (result.equals(result.toLowerCase())) {
      result = result.toUpperCase();
    }
    return result;
  }
796265
public static function convertFromWhiteSpace($value)
    {
        //check for inline linebreaks
        $search = array('\r', '\n', '\f', '\t', '\v');
        $value  = str_replace($search, ';', $value);

        // replace replacement characters regular spaces
        $value = str_replace('�', ' ', $value);

        //convert real linebreaks
        return preg_replace('/(?:\n|\r|\v)/m', '  ', $value);
    }
961533
protected function whitespace()
    {
        $gotWhite = false;

        while (preg_match(static::$whitePattern, $this->buffer, $m, null, $this->count)) {
            if (isset($m[1]) && empty($this->commentsSeen[$this->count])) {
                $this->appendComment([Type::T_COMMENT, $m[1]]);

                $this->commentsSeen[$this->count] = true;
            }

            $this->count += strlen($m[0]);
            $gotWhite = true;
        }

        return $gotWhite;
    }
856527
protected function parseConditionList($conditionList)
    {
        $charset = $this->getCharset();

        $conditions = [];
        foreach (Condition::splitNestedConditions($conditionList) as $normalizedConditionList) {
            $normalizedConditions = [];
            $currentCondition = "";

            if (preg_match('/[^\x00-\x7f]/', $normalizedConditionList)) {
                $isAscii = false;
                $strLen  = mb_strlen($normalizedConditionList, $charset);
                $getAnd  = function($i) use ($normalizedConditionList){return strtolower(substr($normalizedConditionList, $i, 5));};
            } else {
                $isAscii = true;
                $strLen = strlen($normalizedConditionList);
                $getAnd  = function($i) use ($charset, $normalizedConditionList){return mb_strtolower(mb_substr($normalizedConditionList, $i, 5, $charset), $charset);};
            }

            for ($i = 0, $j = $strLen; $i < $j; $i++) {
                if ($isAscii === true) {
                    //$char = substr($normalizedConditionList, $i, 1);
                    $char = $normalizedConditionList[$i];
                } else {
                    $char = mb_substr($normalizedConditionList, $i, 1, $charset);
                }

                if ($char === " " && $getAnd($i) === " and ") {
                    $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f"));
                    $currentCondition = "";
                    $i += (5 - 1);
                } else {
                    $currentCondition .= $char;
                }
            }
            $currentCondition = trim($currentCondition, " \r\n\t\f");
            if ($currentCondition !== "") {
                $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f"));
            }

            foreach ($normalizedConditions as $normalizedCondition) {
                $conditions[] = $normalizedCondition;
            }
        }

        return $conditions;
    }