| @@ 214-223 (lines=10) @@ | ||
| 211 | * |
|
| 212 | * @return Stringy Object with a trimmed $str |
|
| 213 | */ |
|
| 214 | public function trim($chars = null) |
|
| 215 | { |
|
| 216 | if (!$chars) { |
|
| 217 | $chars = '[:space:]'; |
|
| 218 | } else { |
|
| 219 | $chars = preg_quote($chars, '/'); |
|
| 220 | } |
|
| 221 | ||
| 222 | return $this->regexReplace("^[$chars]+|[$chars]+\$", ''); |
|
| 223 | } |
|
| 224 | ||
| 225 | /** |
|
| 226 | * Replaces all occurrences of $pattern in $str by $replacement. |
|
| @@ 1756-1765 (lines=10) @@ | ||
| 1753 | * |
|
| 1754 | * @return Stringy Object with a trimmed $str |
|
| 1755 | */ |
|
| 1756 | public function trimLeft($chars = null) |
|
| 1757 | { |
|
| 1758 | if (!$chars) { |
|
| 1759 | $chars = '[:space:]'; |
|
| 1760 | } else { |
|
| 1761 | $chars = preg_quote($chars, '/'); |
|
| 1762 | } |
|
| 1763 | ||
| 1764 | return $this->regexReplace("^[$chars]+", ''); |
|
| 1765 | } |
|
| 1766 | ||
| 1767 | /** |
|
| 1768 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 1776-1785 (lines=10) @@ | ||
| 1773 | * |
|
| 1774 | * @return Stringy Object with a trimmed $str |
|
| 1775 | */ |
|
| 1776 | public function trimRight($chars = null) |
|
| 1777 | { |
|
| 1778 | if (!$chars) { |
|
| 1779 | $chars = '[:space:]'; |
|
| 1780 | } else { |
|
| 1781 | $chars = preg_quote($chars, '/'); |
|
| 1782 | } |
|
| 1783 | ||
| 1784 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 1785 | } |
|
| 1786 | ||
| 1787 | /** |
|
| 1788 | * Truncates the string to a given length. If $substring is provided, and |
|