public static function trim($s, $charlist = " \t\n\r\v ")
{
$charlist = preg_quote($charlist, '#');
$s = preg_replace('#^[' . $charlist . ']+|[' . $charlist . ']+\\z#u', '', $s);
if (preg_last_error()) {
throw new Latte\RegexpException(NULL, preg_last_error());
}
return $s;
}