Подстрока в строке a
bcdeahopwunshslge
var str = 'abcdeahopwunshslge',
limit,
maxSS = '',
j,
indx,
arr = [];
for(var i = 0; i < str.length; i++) {
arr[i] = '';
j = i ;
limit = str.length;
while(j < limit) {
arr[i] += str[j];
indx = str.indexOf(str[j], j + 1);
if(indx >= 0 && limit > indx ) { limit = indx;}
j++;
}
}
for (var i = 0; i < arr.length; i++) {
if (maxSS.length < arr[i].length) { maxSS = arr[i];}
}
alert(maxSS);