-
Search for a certain letter in the last line of a text
I am trying to search for a certain letter in the last line of a text
with always different numbers of lines. I have already managed the
search for the letter, I am only missing the possibility to limit the
search to the last line. Sometimes it is only one line and sometimes two
or even more.var t = sourceRectAtTime().top; var h = sourceRectAtTime().height; var y = t + h; var l = y-5; var Q = y-3.5; var J = y-4;
var txt = text.sourceText;
var findlower = txt.includes(“q”)||txt.includes(“p”)||txt.includes(“g”)||txt.includes(“j”)||txt.includes(“y”);
var findQ = txt.includes(“Q”);
var findJ = txt.includes(“J”);if(findlower == true){[0,l]}
else if(findJ == true){[0,J]}
else if(findQ == true){[0,Q]}
else [0,y];I tried it with .split(“r”)[x]; but I can only select a certain line, which doesn’t help if I don’t know which one is the last.
Thanks for helping me!