diff --git a/4dev/tests/Convert/CoreLibsConvertStringsTest.php b/4dev/tests/Convert/CoreLibsConvertStringsTest.php index 26c635eb..017c4ec3 100644 --- a/4dev/tests/Convert/CoreLibsConvertStringsTest.php +++ b/4dev/tests/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-あ'], '', diff --git a/www/admin/class_test.strings.php b/www/admin/class_test.strings.php index 95fb3f69..fe2d0c75 100644 --- a/www/admin/class_test.strings.php +++ b/www/admin/class_test.strings.php @@ -141,6 +141,7 @@ print "[B] LAST PREGE ERROR: " . preg_last_error() . " -> " . Strings::getLastRegexErrorString() . " -> " . preg_last_error_msg() . "
"; $base_strings = [ + 'abcddfff', 'A-Z', 'a-z', 'A-Za-z', diff --git a/www/lib/CoreLibs/Convert/Strings.php b/www/lib/CoreLibs/Convert/Strings.php index dd30b470..e4e40f53 100644 --- a/www/lib/CoreLibs/Convert/Strings.php +++ b/www/lib/CoreLibs/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) {