| @@ 276-285 (lines=10) @@ | ||
| 273 | * |
|
| 274 | * @return Stringy Object with a trimmed $str |
|
| 275 | */ |
|
| 276 | public function trim($chars = null) |
|
| 277 | { |
|
| 278 | if (!$chars) { |
|
| 279 | $chars = '[:space:]'; |
|
| 280 | } else { |
|
| 281 | $chars = preg_quote($chars, '/'); |
|
| 282 | } |
|
| 283 | ||
| 284 | return $this->regexReplace("^[$chars]+|[$chars]+\$", ''); |
|
| 285 | } |
|
| 286 | ||
| 287 | /** |
|
| 288 | * Replaces all occurrences of $pattern in $str by $replacement. |
|
| @@ 1842-1851 (lines=10) @@ | ||
| 1839 | * |
|
| 1840 | * @return Stringy Object with a trimmed $str |
|
| 1841 | */ |
|
| 1842 | public function trimLeft($chars = null) |
|
| 1843 | { |
|
| 1844 | if (!$chars) { |
|
| 1845 | $chars = '[:space:]'; |
|
| 1846 | } else { |
|
| 1847 | $chars = preg_quote($chars, '/'); |
|
| 1848 | } |
|
| 1849 | ||
| 1850 | return $this->regexReplace("^[$chars]+", ''); |
|
| 1851 | } |
|
| 1852 | ||
| 1853 | /** |
|
| 1854 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 1862-1871 (lines=10) @@ | ||
| 1859 | * |
|
| 1860 | * @return Stringy Object with a trimmed $str |
|
| 1861 | */ |
|
| 1862 | public function trimRight($chars = null) |
|
| 1863 | { |
|
| 1864 | if (!$chars) { |
|
| 1865 | $chars = '[:space:]'; |
|
| 1866 | } else { |
|
| 1867 | $chars = preg_quote($chars, '/'); |
|
| 1868 | } |
|
| 1869 | ||
| 1870 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 1871 | } |
|
| 1872 | ||
| 1873 | /** |
|
| 1874 | * Truncates the string to a given length. If $substring is provided, and |
|