|
@@ 2966-2982 (lines=17) @@
|
| 2963 |
|
* |
| 2964 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 2965 |
|
*/ |
| 2966 |
|
public static function ltrim($str = '', $chars = INF) |
| 2967 |
|
{ |
| 2968 |
|
$str = (string)$str; |
| 2969 |
|
|
| 2970 |
|
if (!isset($str[0])) { |
| 2971 |
|
return ''; |
| 2972 |
|
} |
| 2973 |
|
|
| 2974 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 2975 |
|
if ($chars === INF || !$chars) { |
| 2976 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 2977 |
|
} |
| 2978 |
|
|
| 2979 |
|
$chars = INF === $chars ? '\s' : self::rxClass($chars); |
| 2980 |
|
|
| 2981 |
|
return preg_replace("/^{$chars}+/u", '', $str); |
| 2982 |
|
} |
| 2983 |
|
|
| 2984 |
|
/** |
| 2985 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 3478-3494 (lines=17) @@
|
| 3475 |
|
* |
| 3476 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 3477 |
|
*/ |
| 3478 |
|
public static function rtrim($str = '', $chars = INF) |
| 3479 |
|
{ |
| 3480 |
|
$str = (string)$str; |
| 3481 |
|
|
| 3482 |
|
if (!isset($str[0])) { |
| 3483 |
|
return ''; |
| 3484 |
|
} |
| 3485 |
|
|
| 3486 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3487 |
|
if ($chars === INF || !$chars) { |
| 3488 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 3489 |
|
} |
| 3490 |
|
|
| 3491 |
|
$chars = INF === $chars ? '\s' : self::rxClass($chars); |
| 3492 |
|
|
| 3493 |
|
return preg_replace("/{$chars}+$/u", '', $str); |
| 3494 |
|
} |
| 3495 |
|
|
| 3496 |
|
/** |
| 3497 |
|
* rxClass |