diff -u b/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php --- b/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -735,12 +735,12 @@ // Determine if the string has 'or' operators (plus signs) or 'and' // operators (commas) and split the string accordingly. - if (preg_match('/^([\w0-9-_\.\#\&\/\(\)]+[+ ]+)+[\w0-9-_\.\#\&\/\(\)]+$/u', $str)) { + if (preg_match(HandlerBase::generatePattern('+'), $str)) { // The '+' character in a query string may be parsed as ' '. $operator = 'or'; $value = preg_split('/[+ ]/', $str); } - elseif (preg_match('/^([\w0-9-_\.\#\&\/\(\)]+[, ]+)*[\w0-9-_\.\#\&\/\(\)]+$/u', $str)) { + elseif (preg_match(HandlerBase::generatePattern(','), $str)) { $operator = 'and'; $value = explode(',', $str); } @@ -876,2 +876,10 @@ + /** + * Pass in a string to be added to an auto generated pattern. + */ + private static function generatePattern($string = ',') { + $op = ($string === ',') ? '*' : '+'; + return '/^([\w0-9-_\.\#\&\/\(\)]+[' . $string . ' ]+)' . $op . '[\w0-9-_\.\#\&\/\(\)]+$/u'; + } + }