#JavaScript (ES6), 25 bytes <!-- language-all: lang-javascript --> s=>/(.+?)\1*$/.exec(s)[1] [Try it online!][TIO-k2nvzdcg] [JavaScript (Node.js)]: https://nodejs.org [TIO-k2nvzdcg]: https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/Y1k5fQ0/bXjPGUEtFXy@1IjVZo1gz2jD2f3J@XnF@TqpeTn66RpqGUo0aBCppanKhSVmp1UAQFjkNDbUaZAxU8h8A "JavaScript (Node.js) – Try It Online"