I have a string like this:
"Video or movie" "parent" "Media or entertainment" "1" "1" "1" "0" "0"
I would like to split it by the spaces but the space inside the quote should be ignored.
So the splitted strings should be:
"Video or movie"
"parent"
"Media or entertainment"
"1"
...
The language is java.
解决方案
this should do the job for you:
final String s = "\"Video or movie\" \"parent\" \"Media or entertainment\" \"1\" \"1\" \"1\" \"0\" \"0\"";
final String[] t = s.split("(?<=\") *(?=\")");
for (final String x : t) {
System.out.println(x);
}
output:
"Video or movie"
"parent"
"Media or entertainment"
"1"
"1"
"1"
"0"
"0"