-
Count number of line breaks?
Is it possible to identify the number of line breaks in a text box?
I have an expression in a range selector that attempts to identify the final character in a line of text using sourceText.length. However, if there are any line breaks in the text, these breaks are added to the total number of characters and the resulting number is higher than the index of the character that I’m trying to target.
I came up with a clunky solution that looks at the total sourceRect height to guess the number of lines and then subtract any resulting number that’s higher than 1 from the total number of characters, but this gave me odd results in some cases.
Is there a cleaner way to accomplish what I’m trying to do? Either by tallying the line breaks or with a better expression to target the actual index of the last character?