Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions different lengths in source name, with split

  • different lengths in source name, with split

    Posted by Bert Brown on December 3, 2009 at 8:23 pm

    How do I read all the characters in between splits? I only know how to do it with fixed length words.

    I know how to do:
    a[1].charAt(0) + a[1].charAt(1) + a[1].charAt(2) +a[1].charAt(3)

    but how do make this work for variable words lengths? I imagine it has something to do with while loops, but I’ve never been able to figure these out.

    thanks

    Bert Brown replied 16 years, 5 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    December 3, 2009 at 9:38 pm

    Something like this will give you the result “234”. I’m not sure why you’d do it though.

    s = “123.234.345.456”;
    a = s.split(“.”);

    str = “”;
    for ( i = 0; i < a[1].length; i++){ str += a[1][i]; } str Dan

  • Bert Brown

    December 3, 2009 at 9:58 pm

    I’m trying to create text labels next to images based on specific aspects of their file names. But some labels are A-RED-2000.jpeg and some are A2-BLUE-22001.jpeg. I want to be able to duplicate comps and switch the jpegs, and have everything else change according to the one file name.

    thanks, tho. I think this should work

  • Kevin Camp

    December 3, 2009 at 11:05 pm

    i may be missing something, but if you return the specific value of an array, it will return all characters of that array index…

    something simple like this:

    target = thisComp.layer(“A2-BLUE-22001.jpeg”);
    a = target.name.split(“-“);
    a[0] + ” ” + a[1]

    would return A2 BLUE

    and this:

    target = thisComp.layer(“A-RED-2000.jpeg”);
    a = target.name.split(“-“);
    a[0] + ” ” + a[1]

    would return A RED

    is this what you are looking for?

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Bert Brown

    December 4, 2009 at 2:08 pm

    Hmm, this def does the trick. I guess I didnt realize it could be so simple. I thought text made things more complicated.

    thanks guys!

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