constlayerNameNum = parseInt(thisLayer.name.replace(/[^0-9]/g, ""));consttotalText = thisComp.layer("Text_" + layerNameNum).text.sourceText;constpointTextArray = thisComp.layer("PointText_" + layerNameNum).text.sourceText.split("$$");// splitTextByWords 함수 정의functionsplitTextByWords(text, words) {letresult = [];letcurrentIndex = 0;for (leti = 0; i < words.length; i++) {constword = words[i];constindex = text.indexOf(word, currentIndex);if (index !== -1) {// 단어 이전의 텍스트를 결과에 추가if (index > currentIndex) {result.push(text.substring(currentIndex, index).trim()); }result.push(word);currentIndex = index + word.length; }// 해당 단어가 발견되지 않았을 때는 다음 단어를 찾기 위해 현재 인덱스를 유지 }// 마지막 단어 이후의 텍스트를 결과에 추가if (currentIndex < text.length) {result.push(text.substring(currentIndex).trim()); }// 결과 배열에서 빈 문자열을 필터링하여 반환returnresult.filter(word=>word !== "");}// 결과 계산constthisLayerRenderText = splitTextByWords(totalText, pointTextArray);[thisLayerRenderText]
답글 남기기