Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Extendscript .split expression error

  • Extendscript .split expression error

    Posted by Otávio Nascimento on February 9, 2023 at 5:47 pm

    Hi,

    I want to get the second array of the split but Im getting a error in extendscript when the second array doesn’t exist. Is there a solution to make it work in both expression engine?

    text.sourceText.split(",")[1]
    Filip Vandueren replied 3 years, 6 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    February 9, 2023 at 6:02 pm

    It depends on what you want to happen when there’s no comma, but this is one way:

    split = text.sourceText.split(",");
    split.length > 1 ? split[1] : ""
  • Otávio Nascimento

    February 9, 2023 at 7:18 pm

    I want to return nothing and put it inside an array with other characters. So something like this?

    split = text.sourceText.split(",");
    splitOne = split.length > 1 ? split[1] : "";
    splitTwo= split.length > 1 ? split[2] : "";
    splitThree= split.length > 1 ? split[3] : "";
    wordDictionary = [":", ".",splitOne ,splitTwo,splitThree]
  • Filip Vandueren

    February 10, 2023 at 10:59 am

    as a hack you could maybe do this ?

    split = (text.sourceText.value+”,,,”).split(“,”).slice(0,3);

    there will always be at least 3 (possibly empty) items in the array this way

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