Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Getting Number of Words in a Text Layer via Expression.

  • Getting Number of Words in a Text Layer via Expression.

    Posted by Christopher Stearns on November 4, 2016 at 6:09 pm

    Hey Everyone!

    Is there any expression that will return the number of words in a text layer? I’m trying to create a template for a sing-along type effect that will be easy for someone to just rename the text layer, and the effect will automatically update.

    Right now my workaround is having a Slider Control that the user has to use to specify the number of words in the text layer, but I’d really prefer to eliminate that step if it’s possible.

    Thanks for your help!

    EDIT: Never mind! I figured it out thanks to a Dan Ebberts response to another question. The code I ended up with looks like this:

    words = thisComp.layer("first line").name.split(" ");
    words.length

    Christopher Stearns replied 9 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Miguel De mendoza

    November 4, 2016 at 8:10 pm

    You can use the split function and get the length of the result. Let’s assume you only have spaces, comas and dots in the text, you can get the count like this:

    wordsCount = thisComp.layer("Your text layer").text.sourceText.split(/ ,| | \./).length;

  • Christopher Stearns

    November 4, 2016 at 8:27 pm

    That looks like it’d work too, thanks so much!

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