Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions sourceText.split problem

  • sourceText.split problem

  • Chris Scalzo

    June 18, 2018 at 7:23 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

  • Chris Scalzo

    June 18, 2018 at 8:54 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.

  • Dan Ebberts

    June 18, 2018 at 8:57 pm

    Try it this way:

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

    Dan

Viewing 1 - 3 of 3 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy