ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Multiple lines to a single line

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
AD Narayan
Multiple lines to a single line
on Oct 9, 2017 at 10:29:46 pm

Hey hive-mind,

I don't know if this is possible, but I thought I'd ask anyway.

I have a text layer with multiple lines of text that looks like this:
"Line1
Line2
Line3
Line4
Line5"

I'd like to use an expression to force this into the following format:
"Line1, Line2, Line3, Line4, Line5 "

The catch is that the number of lines is variable in our workflow.
I'm able to retrieve the number of lines using the expression below, but I'm struggling with storing each line in an array and then "adding" all the elements of the array up. Don't even know if this is possible, but any help would be appreciated.

thisLayer.text.sourceText.split(/\n|\r/).length;

Lead VFX and Motion Design at Tomorrowland NZ


Return to posts index

Dan Ebberts
Re: Multiple lines to a single line
on Oct 9, 2017 at 10:55:52 pm

Try this:


thisLayer.text.sourceText.replace(/\r?\n|\r/g, ', ')



Dan



Return to posts index

AD Narayan
Re: Multiple lines to a single line
on Oct 9, 2017 at 11:38:14 pm

Ah so elegant! Haha thanks as always. Tell me where to send the beer.

Lead VFX and Motion Design at Tomorrowland NZ


Return to posts index

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