/* 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
{
{
int cnt = 0;
String str
= "This is \"a string\" and this is \"a \\\"nested\\\" string\""; Pattern ptrn = Pattern.compile("\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|\\S+");
Matcher matcher = ptrn.matcher(str);
while (matcher.find()) {
cnt++;
}
matcher.reset();
int idx = 0;
while (matcher.find()) {
result[idx] = matcher.group(0);
idx++;
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwucmVnZXguKjsKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlpbnQgY250ID0gMDsKCQlTdHJpbmcgc3RyID0gIlRoaXMgaXMgXCJhIHN0cmluZ1wiIGFuZCB0aGlzIGlzIFwiYSBcXFwibmVzdGVkXFxcIiBzdHJpbmdcIiI7IAogICAgCVBhdHRlcm4gcHRybiA9IFBhdHRlcm4uY29tcGlsZSgiXCJbXlwiXFxcXF0qKD86XFxcXC5bXlwiXFxcXF0qKSpcInxcXFMrIik7CiAgICAJTWF0Y2hlciBtYXRjaGVyID0gcHRybi5tYXRjaGVyKHN0cik7CiAgICAJd2hpbGUgKG1hdGNoZXIuZmluZCgpKSB7CiAgICAJCWNudCsrOwogICAgCX0KICAgIAlTeXN0ZW0ub3V0LnByaW50bG4oY250KTsKICAgIAlTdHJ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