- def findTheWordsBefore(paragraph):
- import re
- prose = re.compile(r"(\s\w*\s\w*\s\w*)\s*drill")
- List = prose.split(paragraph)
- return List
- with open("how_2_use_drill.txt", "r" ) as source:
- for line in source:
- sentences = findTheWordsBefore(line)
- for s in sentences:
- print s.strip()
|