Im trying to print a txt file using RE to retrieve msg send out from a person
here is what the file looks like
[9/8/18, 10:03:17 PM] Lim :xx xx
xx
xx
xx
[10/8/18, 11:03:17 PM] Tan:yy yy
yy
yy
yy
[10/8/18, 12:03:17 PM] Lim :zz zz
zz
zz
zz
[11/8/18, 10:03:17 PM] Ong:11 11
11
11
11
my code is
import re
name = "Lim"
file = open("_chat.txt", "r")
for line in file:
z = re.findall(r"[\W\d\W\w]",line)
if z: found = (name in line)
if found: print (line)
my output is
[9/8/18, 10:03:17 PM] Lim :xx xx
[10/8/18, 12:03:17 PM] Lim :zz zz
The result I want is
[14/8/18, 10:03:17 PM] Lim :xx xx
xx
xx
xx
[14/8/18, 10:03:17 PM] Lim :zz zz
zz
zz
zz
How do I print the next few lines? There may be more than 3 lines.