function fn(b) {
for (var c = "", f = /(\S)(?=\S+?\1)/, a = 0; a < b.length; a++)
for (var d = a + 1; d <= b.length; d++) {
var e = b.substring(a, d);
if (f.test(e)) break;
else e.length > c.length && (c = e)
}
return c
};
var str = 'abcdeahopwunshslge';
alert(fn(str));