将字符串拆分/分割在引号上 [英] Divide/split a string on quotation marks
本文介绍了将字符串拆分/分割在引号上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下字符串:
我会肯定喜欢去上学。
现在,我想在椭圆分割这个字符串,也就是我想得到以下输出:
-
-
去上学
-
。
解决方案
我的case你的意思是引号()而不是省略号,使用
String.split
:
String text =我会\肯定是喜欢\去学校\\;
String [] result = text.split(\);
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
.
解决方案
I case you meant quotation mark ("
) instead of ellipsis, the easiest solution is to use String.split
:
String text = "I would \"surely\" like to \"go to school\".";
String[] result = text.split("\"");
这篇关于将字符串拆分/分割在引号上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文