我想返回关键词,一切都在继续,直到它达到第一个可能的句号。例如,如果句子是
The house was full of tables and chairs. He did not like them.
如果关键词是房子,我想返回
house was full of tables and chairs.
非常感谢!
答案 0 :(得分:2)
答案 1 :(得分:2)
var text = "The house was full of tables and chairs. He did not like them."
var match = text.match(/house[^.]*\./)
var res = match && match[0]
console.log(res)