diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php
index f34d0873703..acc99b3160b 100644
--- a/core/modules/views/src/Plugin/views/HandlerBase.php
+++ b/core/modules/views/src/Plugin/views/HandlerBase.php
@@ -818,21 +818,24 @@ public static function breakString($str, $force_int = FALSE) {
     $operator = NULL;
     $value = [];
 
-    // 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)) {
-      // 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)) {
-      $operator = 'and';
-      $value = explode(',', $str);
+    // Remove whitespace, + and , characters from start and end of string.
+    $str = trim($str, " \n\r\t\v\0,+");
+    if ($str !== '') {
+      // Check for 'or' operators (plus signs or spaces) along with a comma.
+      if ((strpos($str, '+') || strpos($str, ' ')) && strpos($str, ',') === FALSE) {
+        $operator = 'or';
+        // Replace plus signs with spaces and split.
+        $value = explode(' ', str_replace('+', ' ', $str));
+      }
+      // Check for 'and' operators (commas) or if the string has only one
+      // word without any delimiters.
+      else {
+        $operator = 'and';
+        $value = explode(',', $str);
+      }
     }
 
-    // Filter any empty matches (Like from '++' in a string) and reset the
-    // array keys. 'strlen' is used as the filter callback so we do not lose
-    // 0 values (would otherwise evaluate == FALSE).
+    // Filter any empty matches and reset array keys.
     $value = array_values(FilterArray::removeEmptyStrings($value));
 
     if ($force_int) {
diff --git a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php
index fa9af239ca3..b46d00d4f86 100644
--- a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php
+++ b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php
@@ -79,6 +79,14 @@ protected function viewsData() {
   public function testBreakString(): void {
     // Check defaults.
     $this->assertEquals((object) ['value' => [], 'operator' => NULL], HandlerBase::breakString(''));
+    // Create a string of 'word' repeated 4000 times, joined by '+' to simulate an "OR" operation.
+    $long_string_or = implode('+', array_fill(0, 4000, 'word'));
+    // Create a string of 'word' repeated 4000 times, joined by ',' to simulate an "AND" operation.
+    $long_string_and = implode(',', array_fill(0, 4000, 'word'));
+    // Create a string of 'word:word1' repeated 4000 times, joined by '+' to simulate an "OR" operation with a regex-like pattern.
+    $long_string_or_regex = implode('+', array_fill(0, 4000, 'word:word1'));
+    // Create a string of 'word:word1' repeated 4000 times, joined by ',' to simulate an "AND" operation with a regex-like pattern.
+    $long_string_and_regex = implode(',', array_fill(0, 4000, 'word:word1'));
 
     // Test ors
     $handler = HandlerBase::breakString('word1 word2+word');
@@ -96,6 +104,18 @@ public function testBreakString(): void {
     $handler = HandlerBase::breakString('wõrd1+wõrd2+wõrd');
     $this->assertEquals(['wõrd1', 'wõrd2', 'wõrd'], $handler->value);
     $this->assertEquals('or', $handler->operator);
+    $handler = HandlerBase::breakString($long_string_or);
+    $this->assertEquals(explode('+', $long_string_or), $handler->value);
+    $this->assertEquals('or', $handler->operator);
+    $handler = HandlerBase::breakString('word:word1+word:word2+word:word3');
+    $this->assertEquals(['word:word1', 'word:word2', 'word:word3'], $handler->value);
+    $this->assertEquals('or', $handler->operator);
+    $handler = HandlerBase::breakString('word:word1 word:word2 word:word3');
+    $this->assertEquals(['word:word1', 'word:word2', 'word:word3'], $handler->value);
+    $this->assertEquals('or', $handler->operator);
+    $handler = HandlerBase::breakString($long_string_or_regex);
+    $this->assertEquals(explode('+', $long_string_or_regex), $handler->value);
+    $this->assertEquals('or', $handler->operator);
 
     // Test ands.
     $handler = HandlerBase::breakString('word1,word2,word');
@@ -113,11 +133,23 @@ public function testBreakString(): void {
     $handler = HandlerBase::breakString('wõrd1,wõrd2,wõrd');
     $this->assertEquals(['wõrd1', 'wõrd2', 'wõrd'], $handler->value);
     $this->assertEquals('and', $handler->operator);
+    $handler = HandlerBase::breakString($long_string_and);
+    $this->assertEquals(explode(',', $long_string_and), $handler->value);
+    $this->assertEquals('and', $handler->operator);
+    $handler = HandlerBase::breakString('word:word1,word:word2,word:word3');
+    $this->assertEquals(['word:word1', 'word:word2', 'word:word3'], $handler->value);
+    $this->assertEquals('and', $handler->operator);
+    $handler = HandlerBase::breakString($long_string_and_regex);
+    $this->assertEquals(explode(',', $long_string_and_regex), $handler->value);
+    $this->assertEquals('and', $handler->operator);
 
     // Test a single word
     $handler = HandlerBase::breakString('word');
     $this->assertEquals(['word'], $handler->value);
     $this->assertEquals('and', $handler->operator);
+    $handler = HandlerBase::breakString('word:word1');
+    $this->assertEquals(['word:word1'], $handler->value);
+    $this->assertEquals('and', $handler->operator);
 
     $s1 = $this->randomMachineName();
     // Generate three random numbers which can be used below;
