/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/* Name of the class has to be "Main" only if the class is public. */
class TestReg
{
	public static void main (String[] args) throws java.lang.Exception
	{
		        String[] samples = {"outside \"inside\" outside",
                "outside \"ins\\\"ide\" outside",
                "outside \"\\\\\"",
                "Hello \"my\" name is \"Andy\", nice to meet you.", 
                "Foo \"bar\" baz\\\"\\\\\"qux\".",
                "\"\\\"\" \"\\\"\" \\\\\"s\\\"s\\\\\"g \\\"x\"x\"\n", "\"ddd\" \"asdasd\" dfdsf \"asdasd\\\"\"" +
                " \"\\\\\" \"something\\g\" \"\" Hello \"my\" name is \"Andy\", nice to meet you. Foo \"bar\" " +
                "baz\\\"\\\\\"qux\".\"\\\"\" \"\\\"\" \\\\\"s\\\"s\\\\\"g \\\"x\"x\""};
        TestReg testReg = new TestReg();
        for(String sample : samples) {
            System.out.println(testReg.testIt(sample));
        }
	}
	
	    public String testIt(String sample){
        Matcher matcher = Pattern.compile("(?<!.\\G\")(?<!(?:^|[^\\\\])(?:\\\\\\\\){0,20}\\\\\")(?:(?<=\")(?:(?:\\\\\\\\|\\\\\"|[^\"])+?)(?=\")|(?<=\")(?=\"))").
                matcher(sample);

        String result = "";
        while(matcher.find()){
            result += matcher.group() +", ";
        }

        return result;
    }
	
	
	
}