Hey I think i got a set up that should work for you. You’ll have to set up the layers exactly like this for it to work though.
So in my example i have three text layers: Left , Center, Right. The anchor point for the Left layer should be bottom right corner, It should be bottom center for the Center layer, and bottom left corner for the Right layer. The Left and Right can be set to left align text (paragraph option tab) and Center needs to be set to Center Text.
In the position property of the Left layer use this:
s = thisComp.layer(“center”);
xw = s.sourceRectAtTime(time-s.inPoint,true).width/2;
x = thisComp.layer(“center”).transform.position[0];
y = thisComp.layer(“center”).transform.position[1];
[x-xw-20,y]
and in the right layer use this:
s = thisComp.layer(“center”);
xw = s.sourceRectAtTime(time-s.inPoint,true).width/2;
x = thisComp.layer(“center”).transform.position[0];
y = thisComp.layer(“center”).transform.position[1];
[x+xw+20,y]
This will lock the side layers to the center layer’s Y position while snapping them to either end of it’s width. The “+20” part of the expression is the padding that you can adjust.
