-
Eliminate line breaks with regex!
Hello everyone!
I’m need a help to “eliminate” the line breaks character count from an expression i’m doing.
The expression reveals the position of the first charactere of a word i set to encounter, and sum with
the word length to reveal the last character position.
t = text.sourceText; //text
w = thisComp.layer("word").text.sourceText; //word do find
IN = t.search(w); //first word's character positon
OUT = IN + w.length; // last word's character position
The main problem is that in this way, when the text have multiples line breaks, it sum a number into my calculation.
That way, as lower line the word is in, it lose the right position.
I would like to set a regex that cut out the line break character count, or at least encounter the line position of the word to substract from my math. eg. If the word is in the line 1, nothing is needed; if the word is in the line 2, substract 1 from IN; if the word is in the line 3, substract 2 from IN and so on.
Thanks in advance!
