|
@@ 3415-3429 (lines=15) @@
|
| 3412 |
|
* |
| 3413 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 3414 |
|
*/ |
| 3415 |
|
public static function ltrim($str = '', $chars = INF) |
| 3416 |
|
{ |
| 3417 |
|
$str = (string)$str; |
| 3418 |
|
|
| 3419 |
|
if (!isset($str[0])) { |
| 3420 |
|
return ''; |
| 3421 |
|
} |
| 3422 |
|
|
| 3423 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3424 |
|
if ($chars === INF || !$chars) { |
| 3425 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 3426 |
|
} |
| 3427 |
|
|
| 3428 |
|
return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 3429 |
|
} |
| 3430 |
|
|
| 3431 |
|
/** |
| 3432 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 4068-4082 (lines=15) @@
|
| 4065 |
|
* |
| 4066 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 4067 |
|
*/ |
| 4068 |
|
public static function rtrim($str = '', $chars = INF) |
| 4069 |
|
{ |
| 4070 |
|
$str = (string)$str; |
| 4071 |
|
|
| 4072 |
|
if (!isset($str[0])) { |
| 4073 |
|
return ''; |
| 4074 |
|
} |
| 4075 |
|
|
| 4076 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 4077 |
|
if ($chars === INF || !$chars) { |
| 4078 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 4079 |
|
} |
| 4080 |
|
|
| 4081 |
|
return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 4082 |
|
} |
| 4083 |
|
|
| 4084 |
|
/** |
| 4085 |
|
* rxClass |