Adobe After Effects Forum
Split() Expression to two lines of text
Split() Expression to two lines of text
by Ryan Kehn on May 28, 2019 at 3:42:45 pm

Hello All,

working with the Split() expression on some text. Referencing the composition title to change a text layer, and that works just fine, but what I'm trying to do is take that source text and split each word into it's own line. coming up stumped.

Original expression is as follows on the Source Text of the text layer:

thisComp.name.split("[delimiter}")[#]

played around a little bit with making that a variable and trying to split that up further but not having any luck.

any advice would be appreciated, thanks!

Ryan Kehn
Creative Director
Van Wagner Productions


Re: Split() Expression to two lines of text
by Tomas Bumbulevičius on May 28, 2019 at 4:09:42 pm

Hey Ryan, few questions:
1. Inside the comp, do you want to additionally break 'splitted' phrase into word per layer?
2. Any chance to see potential comp names?
3. How many text layers do you currently have in the comp?

The thing is - if you are applying your code line to N text layers already(thisComp.name.split("[delimiter}")[#]), and each split part has multiple words - additional amount of layers will be required.

Anyways, answering questions above will give a better understanding.

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



Re: Split() Expression to two lines of text
by Ryan Kehn on May 29, 2019 at 12:20:32 am

Hi Tomas,

Thanks for the reply. Answers to your questions:

1. Essentially, I want a two word string from the comp title to be broken into two lines of text in the comp itself. Want to keep this to one text layer if possible as Element 3D is then being used to extrude the text.

2. Example comp name: "PROMPT_Home Run" where I want "Home Run" to appear on two lines in a single text layer

3. see above:)

Appreciate your insight here!

Ryan Kehn
Creative Director
Van Wagner Productions


Re: Split() Expression to two lines of text
by Oleg Pirogov on May 29, 2019 at 1:13:21 am

Either I didn't get it right, or this should work:
thisComp.name.split("_")[1].replace(" ", "\n")


Re: Split() Expression to two lines of text
by Ryan Kehn on May 29, 2019 at 1:19:43 am

Hot Damn! that did it!

thank you so much!

Ryan Kehn
Creative Director
Van Wagner Productions





© CreativeCOW.net