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

Community Beginner ,
May 19, 2020 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.

TOPICS
Expressions

Views

1.8K

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
community guidelines

correct answers 1 Correct answer

Explorer , May 26, 2020 May 26, 2020
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 spacecomp("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 thisvar mainText = comp("SubjectInfo...

Likes

Translate

Translate
Adobe Community Professional ,
May 19, 2020 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
community guidelines
Community Beginner ,
May 22, 2020 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
community guidelines
Explorer ,
May 26, 2020 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
community guidelines
Community Beginner ,
May 27, 2020 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
community guidelines
New Here ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

LATEST

Hi,
I try it and it works! but it works only in English! I tried in Thai it doesn't work for me TT.

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
community guidelines