Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Specific word in paragraph be a different color

  • Mac Lad

    October 7, 2017 at 6:22 pm

    Sorry Dan, i didn’t put expression selector…but now its working fine ….just for a query can this be worked for multiple words..?
    Is that possible…?

  • Liam Campbell

    October 7, 2017 at 7:28 pm

    The only part of this that I don’t understand is the [textIndex -1] what exactly is this searching for?

  • Dan Ebberts

    October 7, 2017 at 8:41 pm

    You could set it up for multiple words like this:


    wordArray = ["one","two","three","four"];
    words = text.sourceText.replace(/^\s+/, "").split(/\s+/);
    val = 0;
    for (i = 0; i < wordArray.length; i++){
    if (words[textIndex-1] == wordArray[i]){
    val = 100;
    break;
    }
    }
    val

    Dan

  • Dan Ebberts

    October 7, 2017 at 8:47 pm

    words is an array of the words in your text, so it is zero-based (indexing starts with zero). textIndex is the word index into the text itself. It starts with one, so you have to subtract one to retrieve the appropriate word from the array. You wouldn’t have to go through all this if you could use textIndex directly to access the text that it’s indexing.

    Dan

  • Mac Lad

    October 8, 2017 at 7:07 am

    Thanks Dan for awesome help… It also worked with multiple colors by just duplicating Animator and replacing the words from array and changing color parameter

  • Raph Nicolas

    December 28, 2017 at 10:30 pm

    Hi guys, I’m having a similar issue but wondering if this could be adapted to work with external text. I’m importing copy from a spreadsheet (with Dataclay’s Templater) and would like to choose in the spreadsheet which words get highlighted (e.g. yellow instead of white) in the comp’s text box. What would this formula look like if a special character (for example “*”) in the text field marks the word with different color? e.g. “Lorem ipsum *dolor sit amet*, consectetur adipiscing elit” returning “dolor sit amet” in yellow while stripping * away?

  • Roman Lehmann

    March 25, 2018 at 8:12 pm

    I have a text layer and a solid. Is it possible to change the opacity of the solid if the source text in the textlayer equals the word “SUI”?
    Any help is appreciated!

  • Dan Ebberts

    March 25, 2018 at 8:46 pm

    Something like this:

    if(thisComp.layer(“text”).text.sourceText == “SUI”) 100 else 0

    Dan

  • Roman Lehmann

    March 25, 2018 at 8:50 pm

    perfect, that works flawlessly! thank you Dan!

  • Matt Volp

    March 31, 2018 at 7:37 pm

    Hi Dan,

    What about if the word isn’t surrounded by whitespace?

    For example:

    string = “Hello you people!”

    I want to highlight “people” “you”. Not “people!”.

Page 2 of 3

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