Count the number of lines in a text input?

I’m providing a multiline text box where users can copy paste a list of strings (one on each line). At the end of the form I want to count the number of strings he has entered, and display it for confirmation. How can I count the number of newline characters in the input?

Maybe @Xiphware is in a good position to respond if this is possible.

Hello @ks_1,
Maybe. with a trick, translate function can do the job (at least in Enketo).
CountSpecChar_01.xlsx (12.5 KB)

ReducedLength here is the number of newlines
Attention, also counts leading and trailing and multiple newlines.
Leading and trailing might be removed by adding normalize-space function: string-length( normalize-space(…) ).

Kind regards


Thanks @wroos it’s a smart solution.
I think this will work, will let you know. :slight_smile:

1 Like