Forums › Adobe After Effects Expressions › sourceText.split problem
-
sourceText.split problem
-
Chris Scalzo
June 18, 2018 at 7:23 pmin a range selector, I have the following code on a color amount. If the 10th word starts with an “s” or S”, I want it to change the color.
The problem, is if a word before it has 2 spaces before it. It advances the split count; however, the range selector that doesn’t count the double space as a word. (so word 10 is now at text.sourceText.split(” “)[11])
Anyone have any idea of a workaround?
y=text.sourceText.split(" ")[10][0];
if ((y == "s") || (y == "S")) 100 else 0 -
Chris Scalzo
June 18, 2018 at 8:54 pmI found my workaround in this post from the great Dan couple years ago.
https://forums.creativecow.net/readpost/227/33812
Answer: expression selectors.
-
Dan Ebberts
June 18, 2018 at 8:57 pmTry it this way:
txt = text.sourceText.replace(/ +(?= )/g,”);
y=txt.split(” “)[10][0];
if ((y == “s”) || (y == “S”)) 100 else 0Dan
Log in to reply.