| @@ 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. |
|
| @@ 1979-1988 (lines=10) @@ | ||
| 1976 | * |
|
| 1977 | * @return Stringy Object with a trimmed $str |
|
| 1978 | */ |
|
| 1979 | public function trimLeft($chars = null) |
|
| 1980 | { |
|
| 1981 | if (!$chars) { |
|
| 1982 | $chars = '[:space:]'; |
|
| 1983 | } else { |
|
| 1984 | $chars = preg_quote($chars, '/'); |
|
| 1985 | } |
|
| 1986 | ||
| 1987 | return $this->regexReplace("^[$chars]+", ''); |
|
| 1988 | } |
|
| 1989 | ||
| 1990 | /** |
|
| 1991 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 1999-2008 (lines=10) @@ | ||
| 1996 | * |
|
| 1997 | * @return Stringy Object with a trimmed $str |
|
| 1998 | */ |
|
| 1999 | public function trimRight($chars = null) |
|
| 2000 | { |
|
| 2001 | if (!$chars) { |
|
| 2002 | $chars = '[:space:]'; |
|
| 2003 | } else { |
|
| 2004 | $chars = preg_quote($chars, '/'); |
|
| 2005 | } |
|
| 2006 | ||
| 2007 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 2008 | } |
|
| 2009 | ||
| 2010 | /** |
|
| 2011 | * Truncates the string to a given length. If $substring is provided, and |
|