Add no dash character list allowed in Strings parseCharacterRanges function
Same rules with returning unique elements array
This commit is contained in:
@@ -141,6 +141,7 @@ print "[B] LAST PREGE ERROR: " . preg_last_error() . " -> "
|
||||
. Strings::getLastRegexErrorString() . " -> " . preg_last_error_msg() . "<br>";
|
||||
|
||||
$base_strings = [
|
||||
'abcddfff',
|
||||
'A-Z',
|
||||
'a-z',
|
||||
'A-Za-z',
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user