Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Multiple lines to a single line

  • Multiple lines to a single line

    Posted by Ad Narayan on October 9, 2017 at 10:29 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

    Ad Narayan replied 8 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 9, 2017 at 10:55 pm

    Try this:


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

    Dan

  • Ad Narayan

    October 9, 2017 at 11:38 pm

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

    Lead VFX and Motion Design at Tomorrowland NZ

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