|
@@ 3166-3180 (lines=15) @@
|
| 3163 |
|
* |
| 3164 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 3165 |
|
*/ |
| 3166 |
|
public static function ltrim($str = '', $chars = INF) |
| 3167 |
|
{ |
| 3168 |
|
$str = (string)$str; |
| 3169 |
|
|
| 3170 |
|
if (!isset($str[0])) { |
| 3171 |
|
return ''; |
| 3172 |
|
} |
| 3173 |
|
|
| 3174 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3175 |
|
if ($chars === INF || !$chars) { |
| 3176 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 3177 |
|
} |
| 3178 |
|
|
| 3179 |
|
return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 3180 |
|
} |
| 3181 |
|
|
| 3182 |
|
/** |
| 3183 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 3770-3784 (lines=15) @@
|
| 3767 |
|
* |
| 3768 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 3769 |
|
*/ |
| 3770 |
|
public static function rtrim($str = '', $chars = INF) |
| 3771 |
|
{ |
| 3772 |
|
$str = (string)$str; |
| 3773 |
|
|
| 3774 |
|
if (!isset($str[0])) { |
| 3775 |
|
return ''; |
| 3776 |
|
} |
| 3777 |
|
|
| 3778 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3779 |
|
if ($chars === INF || !$chars) { |
| 3780 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 3781 |
|
} |
| 3782 |
|
|
| 3783 |
|
return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 3784 |
|
} |
| 3785 |
|
|
| 3786 |
|
/** |
| 3787 |
|
* rxClass |