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
...
Copy link to clipboard
Copied
Without any idea about what expression you use we cannot know.
Mylenium
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
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
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
Copy link to clipboard
Copied
Hi,
I try it and it works! but it works only in English! I tried in Thai it doesn't work for me TT.
Copy link to clipboard
Copied
What if I need to split one line into two. Right now I have a line that splits in one line per word.
thisComp.layer("MAIN TEXT").text.sourceText.split(" ").join("\r");