[code]const text = ":apple: fsdfsd text :apple :apple: banana 2332 :apple: nice :apple:" console.log("ALL APPLES") console.log(text.match(/:apple:/g)) console.log("-------------")
/** * * @param {string} text */ function countApples(text) { const matches = text.matchAll(/(?(? < /div> < /p> Это выход < /p> ALL APPLES [ ':apple:', ':apple:', ':apple:', ':apple:' ] ------------- Text group: fsd text :apple :apple: banana 2332 [ ':apple:' ] ------------- Text group: :apple: nice [ ':apple:' ] ------------- Text group: :apple: [ ':apple:' ] ------------- [/code] У кого -нибудь есть идеи, почему выход из первой текстовой группы - это один: Apple: и нет: Apple :: Apple:?