|
@@ 3228-3242 (lines=15) @@
|
| 3225 |
|
* |
| 3226 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 3227 |
|
*/ |
| 3228 |
|
public static function ltrim($str = '', $chars = INF) |
| 3229 |
|
{ |
| 3230 |
|
$str = (string)$str; |
| 3231 |
|
|
| 3232 |
|
if (!isset($str[0])) { |
| 3233 |
|
return ''; |
| 3234 |
|
} |
| 3235 |
|
|
| 3236 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3237 |
|
if ($chars === INF || !$chars) { |
| 3238 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 3239 |
|
} |
| 3240 |
|
|
| 3241 |
|
return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 3242 |
|
} |
| 3243 |
|
|
| 3244 |
|
/** |
| 3245 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 3844-3858 (lines=15) @@
|
| 3841 |
|
* |
| 3842 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 3843 |
|
*/ |
| 3844 |
|
public static function rtrim($str = '', $chars = INF) |
| 3845 |
|
{ |
| 3846 |
|
$str = (string)$str; |
| 3847 |
|
|
| 3848 |
|
if (!isset($str[0])) { |
| 3849 |
|
return ''; |
| 3850 |
|
} |
| 3851 |
|
|
| 3852 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3853 |
|
if ($chars === INF || !$chars) { |
| 3854 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 3855 |
|
} |
| 3856 |
|
|
| 3857 |
|
return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 3858 |
|
} |
| 3859 |
|
|
| 3860 |
|
/** |
| 3861 |
|
* rxClass |