1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-09-03 01:52:43 +02:00

Add removeLeft() and removeRight()

This commit is contained in:
Daniel St. Jules
2013-07-27 17:57:43 -04:00
parent 6d927fbf5d
commit a93955162e
6 changed files with 162 additions and 6 deletions

View File

@@ -44,8 +44,12 @@ Note: The methods listed below are subject to change until we reach a 1.0.0 rele
* [at](#at)
* [first](#first)
* [last](#last)
* [ensureLeft](#ensureLeft)
* [ensureRight](#ensureRight)
* [ensureLeft](#ensureleft)
* [ensureRight](#ensureright)
* [chompLeft](#chompleft)
* [chompRight](#chompright)
* [removeLeft](#removeleft)
* [removeRight](#removeright)
* [Tests](#tests)
* [License](#license)
@@ -674,6 +678,32 @@ S::create('foobar')->ensureRight('.com');
S::ensureRight('foobar', '.com'); // 'foobar.com'
```
##### removeLeft
$stringy->removeLeft(string $substring)
S::removeLeft(string $str, string $substring [, string $encoding ])
Removes the prefix $substring if present.
```php
S::create('fòô bàř', 'UTF-8')->removeLeft('fòô ');
S::removeLeft('fòô bàř', 'fòô ', 'UTF-8'); // 'bàř'
```
##### removeRight
$stringy->removeRight(string $substring)
S::removeRight(string $str, string $substring [, string $encoding ])
Removes the suffix $substring if present.
```php
S::create('fòô bàř', 'UTF-8')->removeRight(' bàř');
S::removeRight('fòô bàř', ' bàř', 'UTF-8'); // 'fòô'
```
## TODO
**count** => substr_count
@@ -698,10 +728,6 @@ S::ensureRight('foobar', '.com'); // 'foobar.com'
**isBlank**
**chompLeft**
**chompRight**
## Tests
[![Build Status](https://travis-ci.org/danielstjules/Stringy.png)](https://travis-ci.org/danielstjules/Stringy)