consider I have a string as following,
\n this is a paragraph. please ignore \n this is a only for testing. please ignore \n
I have a search word as "only for testing"
. and I want to get the sentence which contains "only for testing"
with in the \n
the search word resides.
In this case the output will be
this is a only for testing. please ignore
.
If I give paragraph
as search word I should get the output as
this is a paragraph. please ignore
I have tried
test_str = "\\n this is a paragraph. please ignore \\n this is a only for testing. please ignore \\n"
pattern = re.compile("\\\\n(.+?)\\\\n")
match = pattern.findall(test_str)
But not working as expected