| @@ 284-293 (lines=10) @@ | ||
| 281 | * |
|
| 282 | * @return static Object with a trimmed $str |
|
| 283 | */ |
|
| 284 | public function trim($chars = null) |
|
| 285 | { |
|
| 286 | if (!$chars) { |
|
| 287 | $chars = '[:space:]'; |
|
| 288 | } else { |
|
| 289 | $chars = preg_quote($chars, '/'); |
|
| 290 | } |
|
| 291 | ||
| 292 | return $this->regexReplace("^[$chars]+|[$chars]+\$", ''); |
|
| 293 | } |
|
| 294 | ||
| 295 | /** |
|
| 296 | * Replaces all occurrences of $pattern in $str by $replacement. |
|
| @@ 2092-2101 (lines=10) @@ | ||
| 2089 | * |
|
| 2090 | * @return static Object with a trimmed $str |
|
| 2091 | */ |
|
| 2092 | public function trimLeft($chars = null) |
|
| 2093 | { |
|
| 2094 | if (!$chars) { |
|
| 2095 | $chars = '[:space:]'; |
|
| 2096 | } else { |
|
| 2097 | $chars = preg_quote($chars, '/'); |
|
| 2098 | } |
|
| 2099 | ||
| 2100 | return $this->regexReplace("^[$chars]+", ''); |
|
| 2101 | } |
|
| 2102 | ||
| 2103 | /** |
|
| 2104 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 2112-2121 (lines=10) @@ | ||
| 2109 | * |
|
| 2110 | * @return static Object with a trimmed $str |
|
| 2111 | */ |
|
| 2112 | public function trimRight($chars = null) |
|
| 2113 | { |
|
| 2114 | if (!$chars) { |
|
| 2115 | $chars = '[:space:]'; |
|
| 2116 | } else { |
|
| 2117 | $chars = preg_quote($chars, '/'); |
|
| 2118 | } |
|
| 2119 | ||
| 2120 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 2121 | } |
|
| 2122 | ||
| 2123 | /** |
|
| 2124 | * Truncates the string to a given length. If $substring is provided, and |
|