|
@@ 2717-2729 (lines=13) @@
|
| 2714 |
|
* |
| 2715 |
|
* @return string <p>The string with unwanted characters stripped from the left.</p> |
| 2716 |
|
*/ |
| 2717 |
|
public static function ltrim(string $str = '', $chars = INF): string |
| 2718 |
|
{ |
| 2719 |
|
if (!isset($str[0])) { |
| 2720 |
|
return ''; |
| 2721 |
|
} |
| 2722 |
|
|
| 2723 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 2724 |
|
if ($chars === INF || !$chars) { |
| 2725 |
|
return \preg_replace('/^[\pZ\pC]+/u', '', $str); |
| 2726 |
|
} |
| 2727 |
|
|
| 2728 |
|
return \preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
| 2729 |
|
} |
| 2730 |
|
|
| 2731 |
|
/** |
| 2732 |
|
* Returns the UTF-8 character with the maximum code point in the given data. |
|
@@ 3387-3399 (lines=13) @@
|
| 3384 |
|
* |
| 3385 |
|
* @return string <p>The string with unwanted characters stripped from the right.</p> |
| 3386 |
|
*/ |
| 3387 |
|
public static function rtrim(string $str = '', $chars = INF): string |
| 3388 |
|
{ |
| 3389 |
|
if (!isset($str[0])) { |
| 3390 |
|
return ''; |
| 3391 |
|
} |
| 3392 |
|
|
| 3393 |
|
// Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories |
| 3394 |
|
if ($chars === INF || !$chars) { |
| 3395 |
|
return \preg_replace('/[\pZ\pC]+$/u', '', $str); |
| 3396 |
|
} |
| 3397 |
|
|
| 3398 |
|
return \preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
| 3399 |
|
} |
| 3400 |
|
|
| 3401 |
|
/** |
| 3402 |
|
* rxClass |