Aeneid = ExampleData[{"Text", "AeneidEnglish"}];
StringLength[Aeneid]
606071
teststring = StringTake[Aeneid, 1000];
nlargest = 20;
TakeLargestBy[Cases[StringCases[teststring, __, Overlaps -> All], _?PalindromeQ],
StringLength, nlargest] // Flatten // Timing
{16.2909, {"ivi", "t t", "a a", " I ", "ele", "t t", "ovo", " O ",
" I ", "h h", "s s", "g g", "t t", "awa", "ses", "ese", " a ",
"t t", "exe", "s s"}}
MaximalBy[Select[StringJoin /@ Subsequences[Characters[teststring]],
PalindromeQ], StringLength, nlargest] // Timing
{16.9451, {" I ", " I ", "ele", "t t", "a a", "t t", "ivi", "g g",
" O ", "ses", "ovo", " a ", "s s", "h h", "ese", "exe", "t t",
"awa", "t t", "s s"}}
MaximalBy[StringCases[teststring, x : Repeated[_, {2, \[Infinity]}]
/; PalindromeQ[x], Overlaps -> True], StringLength, nlargest] // Timing
{12.1068, {" I ", " I ", "ele", "t t", "a a", "t t", "ivi", "g g",
" O ", "ses", "ovo", " a ", "s s", "h h", "ese", "exe", "t t",
"awa", "t t", "s s"}}
LongestCommonSubsequence[teststring, StringReverse[teststring]]
"tes d"
I declare C.E.'s first solution to be the winner. It is both the fastest and most elegant.
Not sure what is going on with C.E.'s second solution, which appears to fail completely.
PalindromeQ
is new in 10.3.. in case anyone else has issues with this. $\endgroup$ – george2079 Dec 5 '16 at 19:36