Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression to delete unwanted spaces at the beginning of line in a text layer

  • expression to delete unwanted spaces at the beginning of line in a text layer

    Posted by Kirill Skorodelov on June 9, 2016 at 4:59 pm

    Hi, I’m trying to figure out an expression which would delete unwanted spaces at the start of a line in a text layer.

    My text layer “Source Text” parameter is referencing another text layer “textLayer1” and takes the fist line from it with this expression:

    txt=thisComp.layer(“textLayer1”).text.sourceText; //Looking for the text in “textLayer1”
    line=txt.split(“\r”)[0];//extracting first line of text from “textLayer1”

    Now I’d like to delete any number of spaces before the main text starts even if they exist at the “textLayer1”. So at the end I want a text to start with any symbol but not a space.

    Thanks a lot in advance for any suggestions

    Kirill Skorodelov replied 10 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    June 9, 2016 at 5:49 pm

    Try adding this to the end:

    line.replace(/^[ ]+/,””);

    Dan

  • Kirill Skorodelov

    June 9, 2016 at 9:15 pm

    Perfectly works!
    Thanks a million, Dan!

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