|
@@ 2850-2864 (lines=15) @@
|
| 2847 |
|
* |
| 2848 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 2849 |
|
*/ |
| 2850 |
|
public static function ltrim($str = '', $chars = INF) |
| 2851 |
|
{ |
| 2852 |
|
$str = (string)$str; |
| 2853 |
|
|
| 2854 |
|
if (!isset($str[0])) { |
| 2855 |
|
return ''; |
| 2856 |
|
} |
| 2857 |
|
|
| 2858 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 2859 |
|
if ($chars === INF || !$chars) { |
| 2860 |
|
return preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 2861 |
|
} |
| 2862 |
|
|
| 2863 |
|
return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 2864 |
|
} |
| 2865 |
|
|
| 2866 |
|
/** |
| 2867 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 3571-3585 (lines=15) @@
|
| 3568 |
|
* |
| 3569 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 3570 |
|
*/ |
| 3571 |
|
public static function rtrim($str = '', $chars = INF) |
| 3572 |
|
{ |
| 3573 |
|
$str = (string)$str; |
| 3574 |
|
|
| 3575 |
|
if (!isset($str[0])) { |
| 3576 |
|
return ''; |
| 3577 |
|
} |
| 3578 |
|
|
| 3579 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3580 |
|
if ($chars === INF || !$chars) { |
| 3581 |
|
return preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 3582 |
|
} |
| 3583 |
|
|
| 3584 |
|
return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 3585 |
|
} |
| 3586 |
|
|
| 3587 |
|
/** |
| 3588 |
|
* rxClass |