Denote a string:
string = 'Other unwanted text here and start here: This is the first sentence.\nIt is the second one.\nNow, this is the third one.\nThis is not I want.\n'
I want to extract the first three sentence, that is,
This is the first sentence.\nIt is the second one.\nNow, this is the third one.
Apparently, the following regular expression does not work:
re.search('(?<=This)(.*?)(?=\n)', string)
What is the correct expression for extracting text between This and the third \n?
Thanks.
\nNow ...instead of\Now. I also think you could split on\nto make it simpler (and join back the first 3 elements of the split using\n)