Well, it depends.
If this is just "in a string" then it's complex; strings don't have any real built in sense of "lines", just of a "line separator" character: '\n'
One way to do it is to get the index of the word - which is trivial - and then count the number of "lines" in the string up to that point. But...there is not built in way to count lines either! This should help you find the lines count: Counting Lines in a String
] - it presents quite a few ways, which are (mostly) easy to modify to only work on a substring without generateing new strings all the time.