Activity › Forums › Adobe After Effects Expressions › Word Split
-
Word Split
Posted by Ilya Sire on March 3, 2020 at 2:49 pmHello,
I got text wrote
“My name is Zuki
Rander”i try to split word using split(” “), it produce result as
My, name, is, Zuki
RanderIt 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 pmUnless 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 amit 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,
Randerit separate Zuki index but still maintaining Rander as new line
-
Scott Mcgee
March 4, 2020 at 8:44 amI 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 amHey 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
Reply to this Discussion! Login or Sign Up