Javascript RegExp for splitting text into sentences and keeping the delimiter

前端 未结 5 1988
青春惊慌失措
青春惊慌失措 2020-11-28 08:31

I am trying to use javascript\'s split to get the sentences out of a string but keep the delimiter eg !?.

So far I have

sentences = text.split(/[\\\         


        
5条回答
  •  一生所求
    2020-11-28 09:36

    Improving on Mia's answer here is a version which also includes ending sentences with no punctuation:

    string.match(/[^.?!]+[.!?]+[\])'"`’”]*|.+/g)
    

提交回复
热议问题