|
@@ 3461-3475 (lines=15) @@
|
| 3458 |
|
* |
| 3459 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 3460 |
|
*/ |
| 3461 |
|
public static function ltrim($str = '', $chars = INF) |
| 3462 |
|
{ |
| 3463 |
|
$str = (string)$str; |
| 3464 |
|
|
| 3465 |
|
if (!isset($str[0])) { |
| 3466 |
|
return ''; |
| 3467 |
|
} |
| 3468 |
|
|
| 3469 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3470 |
|
if ($chars === INF || !$chars) { |
| 3471 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 3472 |
|
} |
| 3473 |
|
|
| 3474 |
|
return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 3475 |
|
} |
| 3476 |
|
|
| 3477 |
|
/** |
| 3478 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 4166-4180 (lines=15) @@
|
| 4163 |
|
* |
| 4164 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 4165 |
|
*/ |
| 4166 |
|
public static function rtrim($str = '', $chars = INF) |
| 4167 |
|
{ |
| 4168 |
|
$str = (string)$str; |
| 4169 |
|
|
| 4170 |
|
if (!isset($str[0])) { |
| 4171 |
|
return ''; |
| 4172 |
|
} |
| 4173 |
|
|
| 4174 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 4175 |
|
if ($chars === INF || !$chars) { |
| 4176 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 4177 |
|
} |
| 4178 |
|
|
| 4179 |
|
return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 4180 |
|
} |
| 4181 |
|
|
| 4182 |
|
/** |
| 4183 |
|
* rxClass |