diff --git a/src/Stringy.php b/src/Stringy.php index e26c24d..7cc3649 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -714,8 +714,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess { $stringy = self::create($this->str, $this->encoding); - $stringy->str = preg_replace("/[^a-zA-Z\d $replacement]/u", '', + $stringy->str = preg_replace("/[^a-zA-Z\d\- $replacement]/u", '', $stringy->toAscii()); + + $stringy->str = preg_replace('/\-/u', ' ', $stringy->str); $stringy->str = $stringy->collapseWhitespace()->str; $stringy->str = str_replace(' ', $replacement, strtolower($stringy)); $stringy->str = preg_replace("/[$replacement]+/u", $replacement, $stringy); diff --git a/tests/CommonTest.php b/tests/CommonTest.php index b1a46cb..aa4e620 100644 --- a/tests/CommonTest.php +++ b/tests/CommonTest.php @@ -345,7 +345,8 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase //array('barzi-i-yarostni', 'бързи и яростни'), array('podekhal-k-podezdu-moego-doma', 'подъехал к подъезду моего дома'), array('foo:bar:baz', 'Foo bar baz', ':'), - array('a_string_with_underscores', 'A_string with_underscores', '_') + array('a_string_with_underscores', 'A_string with_underscores', '_'), + array('a_string_with_dashes', 'A string-with-dashes', '_') ); }