|
@@ 2885-2901 (lines=17) @@
|
| 2882 |
|
* |
| 2883 |
|
* @return string The string with unwanted characters stripped from the left |
| 2884 |
|
*/ |
| 2885 |
|
public static function ltrim($str = '', $chars = INF) |
| 2886 |
|
{ |
| 2887 |
|
$str = (string)$str; |
| 2888 |
|
|
| 2889 |
|
if (!isset($str[0])) { |
| 2890 |
|
return ''; |
| 2891 |
|
} |
| 2892 |
|
|
| 2893 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 2894 |
|
if ($chars === INF || !$chars) { |
| 2895 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 2896 |
|
} |
| 2897 |
|
|
| 2898 |
|
$chars = INF === $chars ? '\s' : self::rxClass($chars); |
| 2899 |
|
|
| 2900 |
|
return preg_replace("/^{$chars}+/u", '', $str); |
| 2901 |
|
} |
| 2902 |
|
|
| 2903 |
|
/** |
| 2904 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 3390-3406 (lines=17) @@
|
| 3387 |
|
* |
| 3388 |
|
* @return string The string with unwanted characters stripped from the right |
| 3389 |
|
*/ |
| 3390 |
|
public static function rtrim($str = '', $chars = INF) |
| 3391 |
|
{ |
| 3392 |
|
$str = (string)$str; |
| 3393 |
|
|
| 3394 |
|
if (!isset($str[0])) { |
| 3395 |
|
return ''; |
| 3396 |
|
} |
| 3397 |
|
|
| 3398 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3399 |
|
if ($chars === INF || !$chars) { |
| 3400 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 3401 |
|
} |
| 3402 |
|
|
| 3403 |
|
$chars = INF === $chars ? '\s' : self::rxClass($chars); |
| 3404 |
|
|
| 3405 |
|
return preg_replace("/{$chars}+$/u", '', $str); |
| 3406 |
|
} |
| 3407 |
|
|
| 3408 |
|
/** |
| 3409 |
|
* rxClass |