🔥

replaceTo

2021/11/08に公開
replaceToAll(): void {
        const regexp = /\[ToAll](.*?)\[\/ToAll] ?/m;
        const result = regexp.exec(this.parsingStr);
        if (result) {
            console.log({
                strLength: result[1].length
            });
            const str = result[1];
            const strLength = result[1].length;
            const sliceIndex = 38;
            const sliceTimes = strLength % sliceIndex;
            const newLine = '<br/>';

            for (let i; i < sliceTimes; i++) {
                str.slice(i, sliceIndex * i);
            }
            const slicedResult = result[1].slice(0, sliceIndex);

            this.parsingStr = this.parsingStr.replace(
                result[0],
                `<div class="message-to">@${result[1]}</div>`
            );
            this.parsedInfo.hasToAll = true;
            this.replaceToAll();
        }
    }

Discussion