|
@@ 3878-3894 (lines=17) @@
|
| 3875 |
|
* |
| 3876 |
|
* @return string The string with unwanted characters stripped from the left |
| 3877 |
|
*/ |
| 3878 |
|
public static function ltrim($str = '', $chars = INF) |
| 3879 |
|
{ |
| 3880 |
|
$str = (string)$str; |
| 3881 |
|
|
| 3882 |
|
if (!isset($str[0])) { |
| 3883 |
|
return ''; |
| 3884 |
|
} |
| 3885 |
|
|
| 3886 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3887 |
|
if ($chars === INF || !$chars) { |
| 3888 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 3889 |
|
} |
| 3890 |
|
|
| 3891 |
|
$chars = INF === $chars ? '\s' : self::rxClass($chars); |
| 3892 |
|
|
| 3893 |
|
return preg_replace("/^{$chars}+/u", '', $str); |
| 3894 |
|
} |
| 3895 |
|
|
| 3896 |
|
/** |
| 3897 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 4385-4401 (lines=17) @@
|
| 4382 |
|
* |
| 4383 |
|
* @return string The string with unwanted characters stripped from the right |
| 4384 |
|
*/ |
| 4385 |
|
public static function rtrim($str = '', $chars = INF) |
| 4386 |
|
{ |
| 4387 |
|
$str = (string)$str; |
| 4388 |
|
|
| 4389 |
|
if (!isset($str[0])) { |
| 4390 |
|
return ''; |
| 4391 |
|
} |
| 4392 |
|
|
| 4393 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 4394 |
|
if ($chars === INF || !$chars) { |
| 4395 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 4396 |
|
} |
| 4397 |
|
|
| 4398 |
|
$chars = INF === $chars ? '\s' : self::rxClass($chars); |
| 4399 |
|
|
| 4400 |
|
return preg_replace("/{$chars}+$/u", '', $str); |
| 4401 |
|
} |
| 4402 |
|
|
| 4403 |
|
/** |
| 4404 |
|
* rxClass |