diff -u b/core/modules/search/src/Tests/SearchExcerptTest.php b/core/modules/search/src/Tests/SearchExcerptTest.php
--- b/core/modules/search/src/Tests/SearchExcerptTest.php
+++ b/core/modules/search/src/Tests/SearchExcerptTest.php
@@ -171,6 +171,12 @@
$result = $this->doSearchExcerpt('Dependency', $text, 'ex');
$this->assertTrue(strpos($result, 'DIC') !== FALSE, 'Search excerpt works with acronym in longer text');
+ // Test a long string with a lot of whitespace in it.
+ $lorem3 = str_replace(' ', str_repeat(" \n", 20), $lorem2);
+ $text = str_repeat($lorem3, 20) . ' ' . $lorem1;
+ $result = $this->doSearchExcerpt('Lìbêró', $text);
+ $this->assertTrue(strpos($result, 'libero') !== FALSE, 'Search excerpt works with caps and accents in longer text with whitespace');
+
$this->verbose('Elapsed time: ' . (microtime(TRUE) - $start_time));
}