|
@@ 3460-3474 (lines=15) @@
|
| 3457 |
|
* |
| 3458 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 3459 |
|
*/ |
| 3460 |
|
public static function ltrim($str = '', $chars = INF) |
| 3461 |
|
{ |
| 3462 |
|
$str = (string)$str; |
| 3463 |
|
|
| 3464 |
|
if (!isset($str[0])) { |
| 3465 |
|
return ''; |
| 3466 |
|
} |
| 3467 |
|
|
| 3468 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3469 |
|
if ($chars === INF || !$chars) { |
| 3470 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 3471 |
|
} |
| 3472 |
|
|
| 3473 |
|
return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 3474 |
|
} |
| 3475 |
|
|
| 3476 |
|
/** |
| 3477 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 4109-4123 (lines=15) @@
|
| 4106 |
|
* |
| 4107 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 4108 |
|
*/ |
| 4109 |
|
public static function rtrim($str = '', $chars = INF) |
| 4110 |
|
{ |
| 4111 |
|
$str = (string)$str; |
| 4112 |
|
|
| 4113 |
|
if (!isset($str[0])) { |
| 4114 |
|
return ''; |
| 4115 |
|
} |
| 4116 |
|
|
| 4117 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 4118 |
|
if ($chars === INF || !$chars) { |
| 4119 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 4120 |
|
} |
| 4121 |
|
|
| 4122 |
|
return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 4123 |
|
} |
| 4124 |
|
|
| 4125 |
|
/** |
| 4126 |
|
* rxClass |