Is it possible to capture specific sentences that contain as a keyword (time)? example:
`I want to capture this part (time) and this part. Not this sentence though because it does not contain our keyword. But also this sentence because it contains (time)'
-Note 1: The time is not in parenthesis originally and represents time frame: e.g: 12:45, 10:45 etc.
-Note 2: I am looking for a regex that captures all sentences when this keyword exists. If the findall function does not find the keyword in the sentence then it continues to the next sentence.
-Note 3: In the end we have a sum of sentences that contain a specific keyword.
I have added some additional information. Testing the codes that you have provided me and a text.
text = "He was there. The terrorist destroyed the building at 23:45 with a remote detonation device. He escaped at 23:58 from the balcony of the terrace. He did not survived. Time of death was 00:14. The police found his body 10 minutes after the explosion"
capture_1 = re.findall("(?:\.|\A)(.*\d*:\d*.*)\.", text , flags=re.DOTALL)
capture_2 = re.findall(r'(\..*)(\d*:\d*)(.*) ',text, flags=re.DOTALL )
capture_1 gives me this:
['He was there. The terrorist destroyed the building at 23:45 with a remote detonation device. He escaped at 23:58 from the balcony of the terrace. He did not survived. Time of death was 00:14'])
capture_2 gives me this:
[('. The terrorist destroyed the building at 23:45 with a remote detonation device. He escaped at 23:58 from the balcony of the terrace. He did not survived. Time of death was 00', ':14', '. The police found his body 10 minutes after the')])
I want the following sentences though: [(. The terrorist destroyed the building at 23:45 with a remote detonation device. He escaped at 23:58 from the balcony of the terrace.Time of death was 00:14')]