| @@ 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. |
|
| @@ 1745-1754 (lines=10) @@ | ||
| 1742 | * |
|
| 1743 | * @return Stringy Object with a trimmed $str |
|
| 1744 | */ |
|
| 1745 | public function trimLeft($chars = null) |
|
| 1746 | { |
|
| 1747 | if (!$chars) { |
|
| 1748 | $chars = '[:space:]'; |
|
| 1749 | } else { |
|
| 1750 | $chars = preg_quote($chars, '/'); |
|
| 1751 | } |
|
| 1752 | ||
| 1753 | return $this->regexReplace("^[$chars]+", ''); |
|
| 1754 | } |
|
| 1755 | ||
| 1756 | /** |
|
| 1757 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 1765-1774 (lines=10) @@ | ||
| 1762 | * |
|
| 1763 | * @return Stringy Object with a trimmed $str |
|
| 1764 | */ |
|
| 1765 | public function trimRight($chars = null) |
|
| 1766 | { |
|
| 1767 | if (!$chars) { |
|
| 1768 | $chars = '[:space:]'; |
|
| 1769 | } else { |
|
| 1770 | $chars = preg_quote($chars, '/'); |
|
| 1771 | } |
|
| 1772 | ||
| 1773 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 1774 | } |
|
| 1775 | ||
| 1776 | /** |
|
| 1777 | * Truncates the string to a given length. If $substring is provided, and |
|