Q159982
by jun68ykt
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
const text = "あかあかあかあかなあかなまやははまや";
const results = new Set();
for (let i=0; i < text.length-2; ++ i) {
if (/^(.+)\1/.test(text.substr(i)))
results.add(RegExp.$1);
}
console.log([...results]); // => ["あかあか", "かあ", "あか", "あかな", "は"]