java 在引号上分割/拆分字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3434348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Divide/split a string on quotation marks
提问by Stole
I have the following string:
我有以下字符串:
I would "surely" like to "go to school".
我“肯定”想“去上学”。
Now, I would like to split this string at the ellipses, that is i would like to get the following output:
现在,我想在椭圆处分割这个字符串,也就是说我想得到以下输出:
I would
surely
like to
go to school
.
我会
一定
喜欢
上学
.
回答by Konrad Rudolph
I case you meant quotation mark (") instead of ellipsis, the easiest solution is to use String.split:
如果您的意思是引号 ( ") 而不是省略号,最简单的解决方案是使用String.split:
String text = "I would \"surely\" like to \"go to school\".";
String[] result = text.split("\"");

