diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index 375c43f..f80f473 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -1285,30 +1285,30 @@ function search_simplify_excerpt_match($key, $text, $offset, $boundary, $langcod
   // If we get here, we have a match. Now find the exact location of the match
   // and the original text that matched. Start by splitting up the text by all
   // potential starting points of the matching text and iterating through them.
-  $split = array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), '_search_excerpt_match_filter');
-  foreach ($split as $value) {
+  $split = array_values(array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), '_search_excerpt_match_filter'));
+
+  $numsplits = count($split);
+  for ($split_index = 0; $split_index < $numsplits; $split_index++) {
+    $value = $split[$split_index];
+
     // Skip starting points before the offset.
     if ($value[1] < $offset) {
       continue;
     }
 
-    // Check a window of 80 characters after the starting point for a match,
-    // based on the size of the excerpt window.
+    // See if there is a match starting here, using the next 80 characters.
     $window = substr($text, $value[1], 80);
     $simplified_window = search_simplify($window);
     if (strpos($simplified_window, $simplified_key) === 0) {
-      // We have a match in this window. Store the position of the match.
-      $pos = $value[1];
-      // Iterate through the text in the window until we find the full original
-      // matching text.
-      $length = strlen($window);
-      for ($i = 1; $i <= $length; $i++) {
-        $keyfound = substr($text, $value[1], $i);
+      // We have a match. See if we can find a substring of complete words that
+      // simplifies down to our text.
+      for ($end_index = $split_index + 1; $end_index < $numsplits; $end_index++) {
+        $keyfound = substr($text, $value[1], $split[$end_index][1] - $value[1] - 1);
         if ($simplified_key == search_simplify($keyfound)) {
+          $pos = $value[1];
           break;
         }
       }
-      break;
     }
   }
 
