ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Word Split

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ilya Sire
Word Split
on Mar 3, 2020 at 2:49:00 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


Return to posts index

Scott McGee
Re: Word Split
on Mar 3, 2020 at 3:29:05 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/);


Return to posts index

Ilya Sire
Re: Word Split
on Mar 4, 2020 at 12:36:40 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


Return to posts index


Scott McGee
Re: Word Split
on Mar 4, 2020 at 8:44:16 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.


Return to posts index

Tomas Bumbulevičius
Re: Word Split
on Mar 4, 2020 at 8:50:14 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]