Categories
AE

[익스프레션] 포인트 텍스트 색칠하기(시작점 찾기)

줄바꿈에 상관없이 포인트 텍스트의 위치를 찾는다

const pointTextArrayNum = 1;

const renderText = thisComp.layer("RenderText")
  .text.sourceText.replace(/\r/g, "");
const pointTextArray = thisComp.layer("PointText")
  .text.sourceText.split("$$");


const findStartPositions = (renderText, pointTextArray, curIndex = 0) =>
	pointTextArray.map(pt => {
		const startIndex = renderText.indexOf(pt, curIndex);
		curIndex = (startIndex > 0 ? startIndex : curIndex) + pt.length;
		return startIndex;
	})

result = findStartPositions(renderText, pointTextArray);

[result[pointTextArrayNum-1] ?? -1]

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다