I have a json file containing texts like:
dr. goldberg offers everything.parking is good.he\'s nice and easy to talk
How can I
You can use the standard library re
module:
import re
line = "dr. goldberg offers everything.parking is good.he's nice and easy to talk"
res = re.search("\.?([^\.]*parking[^\.]*)", line)
if res is not None:
print res.group(1)
It will print parking is good
.
Idea is simple - you search for sentence starting from optional dot character .
, than consume all non-dots, parking
word and the rest of non-dots.
Question mark handles the case where your sentence is in the start of the line.