Find n-th line in string


int findl(string [n])



string - string to search in.

n - 0-based index of line. Default: -1.



Returns 0-based index of first character of n-th line in string. If there are less than n+1 lines, returns -1.


If n is omitted or negative, finds next line. It works in same function only.


QM 2.3.3. Fixed bug: does not work if n omitted.


See also: getl, numlines, foreach, line break characters



 find the second line (line index 1)
str s = "line0[]line1[]line2"
int i = findl(s 1)
out i ;;7 (5 characters in the first line, and 2 characters in the line break)

 for each line
int li
for li 0 1000000000
	i=findl(s -li)
	if(i<0) break
	out i