Highlighted

Two or more lines of text to one line in another comp

Community Beginner ,
May 19, 2020

Copy link to clipboard

Copied

Hi to All. I have an issue. I have a text layer which may consist of one, two or more lines breacked by enter. When I'm adding expression to another layer it getting just first line of main text layer, I want it getting whole text no matter how many lines it have and build one line from it.
Can anyone help me with that. And Thank you in advance.

This should get you all the text no matter how many lines it's on.

comp("SubjectInfo").layer("PropertyName").text.sourceText

 

 Or are you trying to put all the lines on to one line? This is changing any carriage return with a space

comp("SubjectInfo").layer("PropertyName").text.sourceText.replace(/\r/g, " ");

 

 The way you were trying to do it you would need a for loop for the amount of lines and a += to concatenate all the results which would look something like this

var mainText = comp("SubjectInfo").layer("PropertyName").text.sourceText.split(/\r/g);
var printOut = "";

for(i = 0; i < mainText.length; i++){
	
	printOut += mainText[i]+" ";
}
printOut

 

TOPICS
Expressions

Views

502

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Two or more lines of text to one line in another comp

Community Beginner ,
May 19, 2020

Copy link to clipboard

Copied

Hi to All. I have an issue. I have a text layer which may consist of one, two or more lines breacked by enter. When I'm adding expression to another layer it getting just first line of main text layer, I want it getting whole text no matter how many lines it have and build one line from it.
Can anyone help me with that. And Thank you in advance.

This should get you all the text no matter how many lines it's on.

comp("SubjectInfo").layer("PropertyName").text.sourceText

 

 Or are you trying to put all the lines on to one line? This is changing any carriage return with a space

comp("SubjectInfo").layer("PropertyName").text.sourceText.replace(/\r/g, " ");

 

 The way you were trying to do it you would need a for loop for the amount of lines and a += to concatenate all the results which would look something like this

var mainText = comp("SubjectInfo").layer("PropertyName").text.sourceText.split(/\r/g);
var printOut = "";

for(i = 0; i < mainText.length; i++){
	
	printOut += mainText[i]+" ";
}
printOut

 

TOPICS
Expressions

Views

503

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 19, 2020 0
Most Valuable Participant ,
May 19, 2020

Copy link to clipboard

Copied

Without any idea about what expression you use we cannot know.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 19, 2020 0
Community Beginner ,
May 22, 2020

Copy link to clipboard

Copied

Yes, sorry, here is my expression, but it's simple and it will work only with 2 lines.

a=comp("SubjectInfo").layer("PropertyName").text.sourceText.split('\r')[0];
b=comp("SubjectInfo").layer("PropertyName").text.sourceText.split('\r')[1];
a+" "+b

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 22, 2020 0
Explorer ,
May 26, 2020

Copy link to clipboard

Copied

This should get you all the text no matter how many lines it's on.

comp("SubjectInfo").layer("PropertyName").text.sourceText

 

 Or are you trying to put all the lines on to one line? This is changing any carriage return with a space

comp("SubjectInfo").layer("PropertyName").text.sourceText.replace(/\r/g, " ");

 

 The way you were trying to do it you would need a for loop for the amount of lines and a += to concatenate all the results which would look something like this

var mainText = comp("SubjectInfo").layer("PropertyName").text.sourceText.split(/\r/g);
var printOut = "";

for(i = 0; i < mainText.length; i++){
	
	printOut += mainText[i]+" ";
}
printOut

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 26, 2020 0
Costaz LATEST
Community Beginner ,
May 27, 2020

Copy link to clipboard

Copied

You're save my life. This is what I was looking for:

"Or are you trying to put all the lines on to one line? This is changing any carriage return with a space"

comp("SubjectInfo").layer("PropertyName").text.sourceText.replace(/\r/g, " ");

 

Thank you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 27, 2020 1