/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String s
= "value1,\"1\",\"2\",3,\"4,5\",value2"; Pattern pattern = Pattern.compile("\"([^\"]+)\"|(?<=,|^)([^,]*)");
Matcher matcher = pattern.matcher(s);
List<String> res = new ArrayList<String>();
while (matcher.find()){
if (matcher.group(1) != null) {
res.add(matcher.group(1));
} else {
res.add(matcher.group(2));
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguKjsKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQkKCQlTdHJpbmcgcyA9ICJ2YWx1ZTEsXCIxXCIsXCIyXCIsMyxcIjQsNVwiLHZhbHVlMiI7CgkJUGF0dGVybiBwYXR0ZXJuID0gUGF0dGVybi5jb21waWxlKCJcIihbXlwiXSspXCJ8KD88PSx8XikoW14sXSopIik7CgkJTWF0Y2hlciBtYXRjaGVyID0gcGF0dGVybi5tYXRjaGVyKHMpOwoJCUxpc3Q8U3RyaW5nPiByZXMgPSBuZXcgQXJyYXlMaXN0PFN0cmluZz4oKTsKCQl3aGlsZSAobWF0Y2hlci5maW5kKCkpewoJCQlpZiAobWF0Y2hlci5ncm91cCgxKSAhPSBudWxsKSB7CgkJCQlyZXMuYWRkKG1hdGNoZXIuZ3JvdXAoMSkpOwoJCQl9IGVsc2UgewoJCQkJcmVzLmFkZChtYXRjaGVyLmdyb3VwKDIpKTsKCQkJfQoJCX0gCgkJU3lzdGVtLm91dC5wcmludGxuKHJlcyk7IAoJfQp9