| @@ 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. |
|
| @@ 1931-1940 (lines=10) @@ | ||
| 1928 | * |
|
| 1929 | * @return Stringy Object with a trimmed $str |
|
| 1930 | */ |
|
| 1931 | public function trimLeft($chars = null) |
|
| 1932 | { |
|
| 1933 | if (!$chars) { |
|
| 1934 | $chars = '[:space:]'; |
|
| 1935 | } else { |
|
| 1936 | $chars = preg_quote($chars, '/'); |
|
| 1937 | } |
|
| 1938 | ||
| 1939 | return $this->regexReplace("^[$chars]+", ''); |
|
| 1940 | } |
|
| 1941 | ||
| 1942 | /** |
|
| 1943 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 1951-1960 (lines=10) @@ | ||
| 1948 | * |
|
| 1949 | * @return Stringy Object with a trimmed $str |
|
| 1950 | */ |
|
| 1951 | public function trimRight($chars = null) |
|
| 1952 | { |
|
| 1953 | if (!$chars) { |
|
| 1954 | $chars = '[:space:]'; |
|
| 1955 | } else { |
|
| 1956 | $chars = preg_quote($chars, '/'); |
|
| 1957 | } |
|
| 1958 | ||
| 1959 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 1960 | } |
|
| 1961 | ||
| 1962 | /** |
|
| 1963 | * Truncates the string to a given length. If $substring is provided, and |
|