Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static String[] splitToPairs(String Line) { Line = Line.replace(" + ", ", "); ArrayList<String> result = new ArrayList<>(); boolean foundQwote = false; String pair = ""; for (int idx = 0; idx < Line.length(); idx++) { if (Line.charAt(idx) == '"') { foundQwote = !foundQwote; } else if (Line.charAt(idx) == ',') { if (!foundQwote) { result.add(pair.trim()); pair = ""; } else { pair = pair + Line.charAt(idx); } } else { pair = pair + Line.charAt(idx); } } result.add(pair.trim()); return result.toArray(new String[result.size()]); } }