| @@ 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. |
|
| @@ 1735-1744 (lines=10) @@ | ||
| 1732 | * |
|
| 1733 | * @return Stringy Object with a trimmed $str |
|
| 1734 | */ |
|
| 1735 | public function trimLeft($chars = null) |
|
| 1736 | { |
|
| 1737 | if (!$chars) { |
|
| 1738 | $chars = '[:space:]'; |
|
| 1739 | } else { |
|
| 1740 | $chars = preg_quote($chars, '/'); |
|
| 1741 | } |
|
| 1742 | ||
| 1743 | return $this->regexReplace("^[$chars]+", ''); |
|
| 1744 | } |
|
| 1745 | ||
| 1746 | /** |
|
| 1747 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 1755-1764 (lines=10) @@ | ||
| 1752 | * |
|
| 1753 | * @return Stringy Object with a trimmed $str |
|
| 1754 | */ |
|
| 1755 | public function trimRight($chars = null) |
|
| 1756 | { |
|
| 1757 | if (!$chars) { |
|
| 1758 | $chars = '[:space:]'; |
|
| 1759 | } else { |
|
| 1760 | $chars = preg_quote($chars, '/'); |
|
| 1761 | } |
|
| 1762 | ||
| 1763 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 1764 | } |
|
| 1765 | ||
| 1766 | /** |
|
| 1767 | * Truncates the string to a given length. If $substring is provided, and |
|