| @@ 215-224 (lines=10) @@ | ||
| 212 | * |
|
| 213 | * @return Stringy Object with a trimmed $str |
|
| 214 | */ |
|
| 215 | public function trim($chars = null) |
|
| 216 | { |
|
| 217 | if (!$chars) { |
|
| 218 | $chars = '[:space:]'; |
|
| 219 | } else { |
|
| 220 | $chars = preg_quote($chars, '/'); |
|
| 221 | } |
|
| 222 | ||
| 223 | return $this->regexReplace("^[$chars]+|[$chars]+\$", ''); |
|
| 224 | } |
|
| 225 | ||
| 226 | /** |
|
| 227 | * Replaces all occurrences of $pattern in $str by $replacement. |
|
| @@ 1706-1715 (lines=10) @@ | ||
| 1703 | * |
|
| 1704 | * @return Stringy Object with a trimmed $str |
|
| 1705 | */ |
|
| 1706 | public function trimLeft($chars = null) |
|
| 1707 | { |
|
| 1708 | if (!$chars) { |
|
| 1709 | $chars = '[:space:]'; |
|
| 1710 | } else { |
|
| 1711 | $chars = preg_quote($chars, '/'); |
|
| 1712 | } |
|
| 1713 | ||
| 1714 | return $this->regexReplace("^[$chars]+", ''); |
|
| 1715 | } |
|
| 1716 | ||
| 1717 | /** |
|
| 1718 | * Returns a string with whitespace removed from the end of the string. |
|
| @@ 1726-1735 (lines=10) @@ | ||
| 1723 | * |
|
| 1724 | * @return Stringy Object with a trimmed $str |
|
| 1725 | */ |
|
| 1726 | public function trimRight($chars = null) |
|
| 1727 | { |
|
| 1728 | if (!$chars) { |
|
| 1729 | $chars = '[:space:]'; |
|
| 1730 | } else { |
|
| 1731 | $chars = preg_quote($chars, '/'); |
|
| 1732 | } |
|
| 1733 | ||
| 1734 | return $this->regexReplace("[$chars]+\$", ''); |
|
| 1735 | } |
|
| 1736 | ||
| 1737 | /** |
|
| 1738 | * Truncates the string to a given length. If $substring is provided, and |
|