Java - Splitting String based on multiple delimiters

后端 未结 4 1428
广开言路
广开言路 2020-12-06 06:44

I essentially want to split up a string based on the sentences, therefore (for the sake of what I\'m doing), whenever there is a !, ., ?

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 06:59

    String.split takes a regex to split on, so you can simply:

    mystring.split("[!.?:;]");
    

提交回复
热议问题