I am trying to search through a text file for and match part (or all) of the text on two separate lines.
I need to return the line number (within the text file) of the matching string (the first line).

An example text file could be:

*This is some text on the first line  

Here is some more or the second line  

This third line has more text.*

If I tried to find the following string "*second line This third line*" it would return a line number of 2 (or really 1 if 0 is the first line).

I have looked at many similar examples and it seems that I should use the re package, however I cannot workout how to return the line number (either [Python - Find line number from text file](https://stackoverflow.com/questions/41429941/python-find-line-number-from-text-file?rq=1), [Python regex: Search across multilines](https://stackoverflow.com/questions/31518294/python-regex-search-across-multilines), [re.search Multiple lines Python](https://stackoverflow.com/questions/18521319/re-search-multiple-lines-python)

This code finds the string across multiple lines

```
import re

a = open('example.txt','r').read()
if re.findall('second line\nThis third line', a, re.MULTILINE):
    print('found!')

```

The code below reads the text file in loop line by line. I realise it will not find a match for the multiline string because it is reading one line at a time.

```
with open('example.txt') as f:
    for line_no, line in enumerate(f):
        if line == 'second line\nThis third line':
            print ('String found on line: ' + str(line_no))
            break
    else: # for loop ended => line not found
        line_no = -1
        print ('\nString Not found')

```

**Question:** How do i get the code in my first example to return the line number of the text file or place this code is some sort of loop that counts the lines?