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
.
Use method String. split() It returns an array of String, splitted by the character you specified. Save this answer.
The split() method splits a string into an array of substrings. The split() method returns the new array. The split() method does not change the original string. If (" ") is used as separator, the string is split between words.
How to Escape Quotes in a String. To add quoted strings inside of strings, you need to escape the quotation marks. This happens by placing a backslash ( \ ) before the escaped character.
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("\"");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With