开发者

Divide/split a string on quotation marks

开发者 https://www.devze.com 2023-01-10 12:40 出处:网络
I have the following string: I would \"surely\" like to \"go to school\". Now, I would like to split开发者_JAVA百科 this string at the ellipses, that is i would like to get the following output:

I have the following string:

I would "surely" like to "go to school".

Now, I would like to split开发者_JAVA百科 this string at the ellipses, that is i would like to get the following output:

  1. I would

  2. surely

  3. like to

  4. go to school

  5. .


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("\"");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号