标签: javascript regex match
如何通过match()方法从字符串中提取句子?
示例:“等等......发生了什么事?......你错了什么?? - 没什么。似乎我在说......! - 真的??? - 你打赌! “
返回: ["Wait...", "Whats happen?", "Whats wrong with you..?", "-Nothing.", "Seems i've speeking..!", "Realy???", "You bet!"]
["Wait...", "Whats happen?", "Whats wrong with you..?", "-Nothing.", "Seems i've speeking..!", "Realy???", "You bet!"]
答案 0 :(得分:2)
str.match(/(.*?(?:\.|\?|!))(?: |$)/g)
http://jsfiddle.net/akXF3/