Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Split text at irregular intervals

  • Split text at irregular intervals

    Posted by David Cabestany on July 7, 2023 at 7:05 pm

    Is there a way to use the split function to cover more than one element in the array?

    For example, I have a series of headlines that I need to break in two lines, in some cases the first two words go on the top and the third word goes on the bottom but other times is the other way around. I’ve been using the following expression:

    thisComp.name.split("_")[1]

    (for the bottom line) and then I just change the position of "_" on the comp name after I duplicate it but I would like to see if there's a way to avoid that step and instead have an expression that covers the first and second words automatically, I tried [0,1] but it only grabs the 2nd part of the array.

    Thanks in advance for your help.

    Dan Ebberts
    replied 1 year, 11 months ago
    2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    July 8, 2023 at 3:50 pm

    I’m not sure exactly what you’re asking, but if you set your comp name up like this:

    “First_Second_Third”

    Then you could have expressions like this for your first line:

    s = thisComp.name.split("_");
    s[0]

    and this for your second line:

    s = thisComp.name.split("_");
    s[1] + " " + s[2]

    or, like this for your first line:

    s = thisComp.name.split("_");
    s[0] + " " + s[1]

    and this for your second line:

    s = thisComp.name.split("_");
    s[2]

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