| @@ 278-287 (lines=10) @@ | ||
| 275 | * |
|
| 276 | * @return Stringy 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. |
|
| @@ 2049-2058 (lines=10) @@ | ||
| 2046 | * |
|
| 2047 | * @return Stringy Object with a trimmed $str |
|
| 2048 | */ |
|
| 2049 | public function trimLeft($chars = null) |
|
| 2050 | { |
|
| 2051 | if (!$chars) { |
|
| 2052 | $chars = '[:space:]'; |
|
| 2053 | } else { |
|
| 2054 | $chars = preg_quote($chars, '/'); |
|
| 2055 | } |
|
| 2056 | ||
| 2057 | return $this->regexReplace("^[$chars]+", ''); |
|
| 2058 | } |
|
| 2059 | ||
| 2060 | /** |
|
| 2061 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 2069-2078 (lines=10) @@ | ||
| 2066 | * |
|
| 2067 | * @return Stringy Object with a trimmed $str |
|
| 2068 | */ |
|
| 2069 | public function trimRight($chars = null) |
|
| 2070 | { |
|
| 2071 | if (!$chars) { |
|
| 2072 | $chars = '[:space:]'; |
|
| 2073 | } else { |
|
| 2074 | $chars = preg_quote($chars, '/'); |
|
| 2075 | } |
|
| 2076 | ||
| 2077 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 2078 | } |
|
| 2079 | ||
| 2080 | /** |
|
| 2081 | * Truncates the string to a given length. If $substring is provided, and |
|