I’m trying to figure out how to count the number of line breaks in a string. Someone put this brilliant concept in another post the count the number of occurrences of a character:
but I don’t know how to use ‘line break’ instead of ‘a’ in the above. I’m trying to count the number of hard linebreaks so I can resize the height of a widget to accomodate both the number of characters + the number of hard line breaks.
Just replace “a” with “\n” which is a regular expression for “newline” or “end of line” character.
You can also use the local variable, LVAR1, to point to the text of a widget directly, instead of the widget itself, so the algorithm can be [[LVAR1.length - LVAR1.replace ("\n,"").length]]