removes leading and trailing parenthesis from list and map strings

@param   string  $string
@return  string
543941
private static function removeParenthesis(string $string): string
    {
        if (substr($string, 0, 1) === '[' && substr($string, -1) === ']') {
            return substr($string, 1, strlen($string) - 2);
        }

        return $string;
    }
775832
static function TrimLeft($string, $chars = null)
    {
        self::InitEncoding();
        if (!$chars)
            return ltrim($chars);

        return ltrim($string, $chars);
    }
719838
final public static function handlifyString($string)
    {
        $string = preg_replace('/\W+/', '_', $string);
        $string = preg_replace('/([A-Z])/', '_$1', $string);
        $string = strtolower($string);
        $string = preg_replace('/_+/', '_', trim($string, '_'));

        return $string;
    }
287872
public static function spaceless(string $string): string
	{
		$string = self::trim($string);
		$string = self::replace($string, '#\s{2,}#', ' ');
		return $string;
	}
823297
public static function singlelise($string)
    {
        $rules = [
            'ies' => 'y',
            'ves' => 'f',
            's'   => '',
        ];

        foreach ($rules as $ending => $replacement) {
            if ($ending === substr($string, -strlen($ending))) {
                return substr($string, 0, -strlen($ending)) . $replacement;
            }
        }

        return $string . 'Single';
    }
279968
protected function cleanExport($string)
    {
        $quote = '"';
        $slash = '\\';
        $newline = "\n";

        $replaces = array(
            "$slash" => "$slash$slash",
            "$quote" => "$slash$quote",
            "\t"     => '\t',
        );

        $string = str_replace(array_keys($replaces), array_values($replaces), $string);

        $po = $quote . implode("${slash}n$quote$newline$quote", explode($newline, $string)) . $quote;

        // remove empty strings
        return str_replace("$newline$quote$quote", '', $po);
    }
1355648
public static function clean_quotes($string)
    {
        if (static::wrapping_quote_for($string)) {
            $string = substr($string, 1); // remove first character
            $string = substr($string, 0, -1); // remove last
        }

        return $string;
    }
293302
public function sanitizeString($string)
    {
        $string = str_replace('_', '-', GeneralUtility::camelCaseToLowerCaseUnderscored($string));

        while (strpos($string, '--')) {
            $string = str_replace('--', '-', $string);
        }

        return $string;
    }
1351415
public function trim($string, $charlist = null)
    {
        $string = (string)$string;

        if ($charlist === null) {
            return trim($string);
        } else {
            return trim($string, $charlist);
        }
    }
666760
public function filterSlug(string $string): string
    {
        return mb_strtolower(trim((string) preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode((string) preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-'));
    }
808197
private function prepareString($string)
    {
        return str_replace(
            array_keys($this->owner->variables),
            array_values($this->owner->variables),
            $string
        );
    }
973185
public static function underscore($string = null)
    {
        return implode(static::SEPARATOR_UNDERSCORE, array_map(function ($word) {
            return strtolower($word);
        }, preg_split('/([A-Z]*[^A-Z]+)/', static::clear($string), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY)));
    }
693076
public function camelize($string)
    {
        $string = preg_replace('#([A-Z])#', '_\\1', $string);
        $string = strtolower($string);
        $string = trim($string, '_');

        return $string;
    }
1186778
public static function smartExplode($string)
    {
        if (empty($string))
            return array();

        if (is_array($string))
            return $string;

        if (!is_array($string)) {
            if (strpos($string, ';') !== false)
                return explode(';', trim($string, ';'));

            if (strpos($string, ',') !== false)
                return explode(',', trim($string, ','));
        }

        return (array)$string;
    }
1135977
protected function removeBadCharLast( $string ) {
		if ( $string != '' ) {
			$char = ord( $string[strlen( $string ) - 1] );
			$m = array();
			if ( $char >= 0xc0 ) {
				# We got the first byte only of a multibyte char; remove it.
				$string = substr( $string, 0, -1 );
			} elseif ( $char >= 0x80 &&
				  preg_match( '/^(.*)(?:[\xe0-\xef][\x80-\xbf]|' .
							  '[\xf0-\xf7][\x80-\xbf]{1,2})$/', $string, $m ) )
			{
				# We chopped in the middle of a character; remove it
				$string = $m[1];
			}
		}
		return $string;
	}
171033
public static function low($string): string
    {
        $cleaned = Str::low($string);
        $cleaned = Str::trim($cleaned);

        return $cleaned;
    }
143781
private function standardize(string $string): string
    {
        // transform CR or LF to CRLF
        $string = preg_replace('~=0D(?!=0A)|(?<!=0D)=0A~', '=0D=0A', $string);
        // transform =0D=0A to CRLF
        $string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);

        switch (\ord(substr($string, -1))) {
            case 0x09:
                $string = substr_replace($string, '=09', -1);
                break;
            case 0x20:
                $string = substr_replace($string, '=20', -1);
                break;
        }

        return $string;
    }