Skip to main content
1 of 2
Neil
  • 177.2k
  • 12
  • 74
  • 281

JavaScript (ES6), 81 bytes

f=
s=>s.replace(/(?=(.+)\1)/g,(_,m)=>(n=m.length)>l&&(l=n,r=m),l=0)&&s.replace(r,'')
<input oninput=o.textContent=f(this.value,r='')><pre id=o>

The ,r='' prevents the function crashing on invalid input.

Neil
  • 177.2k
  • 12
  • 74
  • 281