Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change the colour of a word in a block of text based on its length

  • Change the colour of a word in a block of text based on its length

    Posted by Nawaz Alamgir on September 27, 2018 at 11:34 am

    I have a block of text, on around 20 lines, what I am trying to do is change the colour of a word based on its length, so all words with a length of 6 (or greater than) characters are RED.

    Should be simple enough but I can’t seem to figure out an expression to call the word length in sourceText.

    Can anyone help?

    Nawaz Alamgir replied 7 years, 10 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    September 27, 2018 at 4:04 pm

    You could add a fill color Animator, then add an Expression Selector, set Based On to Words, and use this for the Amount expression:


    words = text.sourceText.replace(/^\s+/, "").split(/\s+/);
    if (words[textIndex-1].length >= 6 ) 100 else 0

    Dan

  • Kalleheikki Kannisto

    September 27, 2018 at 7:16 pm

    Definitely black magic. ????????

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Nawaz Alamgir

    September 28, 2018 at 1:59 pm

    Thank you for that bit of magic. Works like a charm. You legend.

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