|
@@ 3466-3480 (lines=15) @@
|
| 3463 |
|
* |
| 3464 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 3465 |
|
*/ |
| 3466 |
|
public static function ltrim($str = '', $chars = INF) |
| 3467 |
|
{ |
| 3468 |
|
$str = (string)$str; |
| 3469 |
|
|
| 3470 |
|
if (!isset($str[0])) { |
| 3471 |
|
return ''; |
| 3472 |
|
} |
| 3473 |
|
|
| 3474 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3475 |
|
if ($chars === INF || !$chars) { |
| 3476 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 3477 |
|
} |
| 3478 |
|
|
| 3479 |
|
return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 3480 |
|
} |
| 3481 |
|
|
| 3482 |
|
/** |
| 3483 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 4177-4191 (lines=15) @@
|
| 4174 |
|
* |
| 4175 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 4176 |
|
*/ |
| 4177 |
|
public static function rtrim($str = '', $chars = INF) |
| 4178 |
|
{ |
| 4179 |
|
$str = (string)$str; |
| 4180 |
|
|
| 4181 |
|
if (!isset($str[0])) { |
| 4182 |
|
return ''; |
| 4183 |
|
} |
| 4184 |
|
|
| 4185 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 4186 |
|
if ($chars === INF || !$chars) { |
| 4187 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 4188 |
|
} |
| 4189 |
|
|
| 4190 |
|
return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 4191 |
|
} |
| 4192 |
|
|
| 4193 |
|
/** |
| 4194 |
|
* rxClass |