| @@ 278-287 (lines=10) @@ | ||
| 275 | * |
|
| 276 | * @return static Object with a trimmed $str |
|
| 277 | */ |
|
| 278 | public function trim($chars = null) |
|
| 279 | { |
|
| 280 | if (!$chars) { |
|
| 281 | $chars = '[:space:]'; |
|
| 282 | } else { |
|
| 283 | $chars = preg_quote($chars, '/'); |
|
| 284 | } |
|
| 285 | ||
| 286 | return $this->regexReplace("^[$chars]+|[$chars]+\$", ''); |
|
| 287 | } |
|
| 288 | ||
| 289 | /** |
|
| 290 | * Replaces all occurrences of $pattern in $str by $replacement. |
|
| @@ 2085-2094 (lines=10) @@ | ||
| 2082 | * |
|
| 2083 | * @return static Object with a trimmed $str |
|
| 2084 | */ |
|
| 2085 | public function trimLeft($chars = null) |
|
| 2086 | { |
|
| 2087 | if (!$chars) { |
|
| 2088 | $chars = '[:space:]'; |
|
| 2089 | } else { |
|
| 2090 | $chars = preg_quote($chars, '/'); |
|
| 2091 | } |
|
| 2092 | ||
| 2093 | return $this->regexReplace("^[$chars]+", ''); |
|
| 2094 | } |
|
| 2095 | ||
| 2096 | /** |
|
| 2097 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 2105-2114 (lines=10) @@ | ||
| 2102 | * |
|
| 2103 | * @return static Object with a trimmed $str |
|
| 2104 | */ |
|
| 2105 | public function trimRight($chars = null) |
|
| 2106 | { |
|
| 2107 | if (!$chars) { |
|
| 2108 | $chars = '[:space:]'; |
|
| 2109 | } else { |
|
| 2110 | $chars = preg_quote($chars, '/'); |
|
| 2111 | } |
|
| 2112 | ||
| 2113 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 2114 | } |
|
| 2115 | ||
| 2116 | /** |
|
| 2117 | * Truncates the string to a given length. If $substring is provided, and |
|