mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-09-02 01:22:37 +02:00
Added regexReplace()
This commit is contained in:
17
README.md
17
README.md
@@ -38,6 +38,7 @@ A PHP library with a variety of string manipulation functions with multibyte sup
|
||||
* [padBoth](#padboth)
|
||||
* [padLeft](#padleft)
|
||||
* [padRight](#padright)
|
||||
* [regexReplace](#regexreplace)
|
||||
* [removeLeft](#removeleft)
|
||||
* [removeRight](#removeright)
|
||||
* [replace](#replace)
|
||||
@@ -548,6 +549,22 @@ S::create('foo bar')->padRight(10, '_*');
|
||||
S::padRight('foo bar', 10, '_*'); // 'foo bar_*_'
|
||||
```
|
||||
|
||||
#### regexReplace
|
||||
|
||||
$stringy->regexReplace(string $pattern, string $replacement [, string $options = 'msr'])
|
||||
|
||||
S::regexReplace(string $str, string $pattern, string $replacement [, string $options = 'msr' [, string $encoding ]])
|
||||
|
||||
Replaces all occurrences of $pattern in $str by $replacement. An alias
|
||||
for mb_ereg_replace(). Note that the 'i' option with multibyte patterns
|
||||
in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support
|
||||
in the bundled version of Oniguruma in PHP 5.3.
|
||||
|
||||
```php
|
||||
S::create('fòô ', UTF-8')->regexReplace('f[òô]+\s', 'bàř', 'msr');
|
||||
S::regexReplace('fòô ', 'f[òô]+\s', 'bàř', 'msr', 'UTF-8'); // 'bàř'
|
||||
```
|
||||
|
||||
#### removeLeft
|
||||
|
||||
$stringy->removeLeft(string $substring)
|
||||
|
Reference in New Issue
Block a user