|
|
|
@ -6,6 +6,18 @@ namespace jrosset;
|
|
|
|
|
* Class for “missing” mbstring functions
|
|
|
|
|
*/
|
|
|
|
|
final class MbstringExtended {
|
|
|
|
|
/**
|
|
|
|
|
* Multi-bytes implementation for {@see https://www.php.net/manual/function.trim.php trim}
|
|
|
|
|
*
|
|
|
|
|
* @param string $string The input string
|
|
|
|
|
* @param string $charactersPattern The pattern of characters to trim (delimiter is ”#”, case sensitive) ; default = only spaces
|
|
|
|
|
*
|
|
|
|
|
* @return string The resulting string
|
|
|
|
|
*/
|
|
|
|
|
public static function trim (string $string, string $charactersPattern = '\\s'): string {
|
|
|
|
|
/** @noinspection RegExpUnnecessaryNonCapturingGroup */
|
|
|
|
|
return preg_replace('#(?:^' . $charactersPattern . ')|(?:' . $charactersPattern . '$)#u', '', $string);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Multi-bytes implementation for {@see https://www.php.net/manual/function.ucfirst.php ucfirst}
|
|
|
|
|
*
|
|
|
|
|