=(LEN(LEFT(A1,SEARCH(B1,A1)-1))-LEN(SUBSTITUTE(LEFT(A1,SEARCH(B1,A1)-1),CHAR(10),"")))+1

where A1 is original string
and B1 is search sttrng