爪哇 - 基于多个分隔符分割字符串 [英] Java - Splitting String based on multiple delimiters
本文介绍了爪哇 - 基于多个分隔符分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想主要基于句子分裂字符串,所以(对于我在做什么的缘故),每当有一个!
,
,
,:
,;
。
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 !
, .
, ?
, :
, ;
.
将如何实现这一目标有多个项目的数组分裂?
How would I achieve this with multiple items to split the array with?
谢谢!
推荐答案
<一个href=\"http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#split%28java.lang.String%29\"><$c$c>String.split$c$c>需要一个正则表达式来分割,所以你可以简单的:
String.split
takes a regex to split on, so you can simply:
mystring.split("[!.?:;]");
这篇关于爪哇 - 基于多个分隔符分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文