diff --git a/src/Convert/Strings.php b/src/Convert/Strings.php index dd30b47..e4e40f5 100644 --- a/src/Convert/Strings.php +++ b/src/Convert/Strings.php @@ -287,6 +287,10 @@ class Strings // Remove all spaces $input = str_replace(' ', '', $input); $result = []; + // if there is no - inside, return unique characters as array + if (strpos($input, '-') === false) { + return array_unique(mb_str_split($input)); + } // Find all patterns like "A-Z" (character-dash-character) preg_match_all('/(.)-(.)/u', $input, $matches, PREG_SET_ORDER); foreach ($matches as $match) { diff --git a/test/phpunit/Convert/CoreLibsConvertStringsTest.php b/test/phpunit/Convert/CoreLibsConvertStringsTest.php index 26c635e..017c4ec 100644 --- a/test/phpunit/Convert/CoreLibsConvertStringsTest.php +++ b/test/phpunit/Convert/CoreLibsConvertStringsTest.php @@ -743,6 +743,11 @@ final class CoreLibsConvertStringsTest extends TestCase 'abcdefghijklmnopqrstuvwxyz0123', null, ], + 'range without dashes' => [ + ['abcddfff'], + 'abcdf', + null, + ], 'invalid ranges' => [ ['a-あ', 'A-あ', '0-あ'], '',