Hi.
I think this could work. You still need to do some testing.
Add a scale animator to your text. Set units to index, set mode to subtract and scale to 0.
Then on start and end add these expressions.
txt = text.sourceText.replace(/\r/g,"");
var parts = ["testing", "is a text"];
if(time<0){
val = txt.indexOf(parts[-Math.ceil(time+1)]);
}else{
val = value}
val
txt = text.sourceText.replace(/\r/g,"");
var parts = ["testing", "is a text"];
if(time<0){
val = text.animator("Animator 1").selector("Range Selector 1").start+parts[-Math.ceil(time+1)].length;
}else{
val = txt.length}
val
And when you want to see the text width for some specific word, run:
thisComp.layer("Text Layer").sourceRectAtTime(-1,false).width
-1 means the first word from the array, -2 means the second and so on.