"Your goal is to find the longest recurring substring in the input (ignoring case) and returning a lower-case version of that string."
I was solving a little problem, and wanted to use regex, but the expected output overlaps.
My Code:
let x = "Is this thing on?"
console.log((x.match(/(.+)(?=.*\1)/gi)||[]).sort((a,b)=>b.length-a.length)[0].toLowerCase())
Expected answer: "is thi"
My answer: "is th"
Is it possible to solve this problem using regex? If so, how?