ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

sourceText.split problem

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris Scalzo
sourceText.split problem
on Jun 18, 2018 at 7:23:07 pm

in 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


Return to posts index

Chris Scalzo
Re: sourceText.split problem
on Jun 18, 2018 at 8:54:58 pm

I found my workaround in this post from the great Dan couple years ago.

https://forums.creativecow.net/readpost/227/33812

Answer: expression selectors.


Return to posts index

Dan Ebberts
Re: sourceText.split problem
on Jun 18, 2018 at 8:57:09 pm

Try it this way:

txt = text.sourceText.replace(/ +(?= )/g,'');
y=txt.split(" ")[10][0];
if ((y == "s") || (y == "S")) 100 else 0


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]