Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Ilya Sire on March 3, 2020 at 2:49 pm

    Hello,
    I got text wrote
    “My name is Zuki
    Rander”

    i try to split word using split(” “), it produce result as
    My, name, is, Zuki
    Rander

    It count Zuki Rander as 1 index. How can i get Zuki index separated from Rander index?

    Thanks

    Tomas Bumbulevičius replied 6 years, 2 months ago 3 Members · 4 Replies
  • 4 Replies
  • Scott Mcgee

    March 3, 2020 at 3:29 pm

    Unless someone says differently.

    split(” “) splits based on a space gap. Because Rander is on the next line the space isn’t taken into account and you need to include a split(“\r”). I don’t know how to use multiple delimiters, but Regex will work

    text.sourceText.split(/\s/);

  • Ilya Sire

    March 4, 2020 at 12:36 am

    it worked and text layer become My,name,is,Zuki,Rander

    But how can i get this structure without it get rid new line?
    My, name, is, Zuki,
    Rander

    it separate Zuki index but still maintaining Rander as new line

  • Scott Mcgee

    March 4, 2020 at 8:44 am

    I can’t think of a tidier way to do this other than this then

    r = text.sourceText.split(“\r”);
    r[1].split(” “)[0]

    So your first [ ] is referring to line and the second [ ] is referring to word.

  • Tomas Bumbulevičius

    March 4, 2020 at 8:50 am

    Hey Ilya, can you specify what later you are doing with split text array? Because, you could simply ‘build it’ back into a string again, just comma separated + return carriage. Yet, this will depend on what you are doing with it futher.

    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.
    Boxer – Dynamic Text Boxes Template with a Live Preview

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