"aac".replace(/(?<=\1(\w))\w/gi , (...a) => console.log(a)); "caa".replace(/\w(?=(\w)\1)/gi , (...a) => console.log(a));