Possible Duplicate:
Javascript code to parse CSV data
i have this string:
"display, Name" <test@test.com>, display" Name <test@test.com>, test@test.com
i want to separate this string into an array
array[0] = "\"display, Name\" <test@test.com>"
array[1] = "display\" Name <test@test.com>"
array[2] = "test@test.com"
here is my code:
var comma = inQuotes = false;
for(var i=0;i<str.length;i++) {
            if (str[i] == '"') inQuotes = !inQuotes;
            comma = (str[i] == "," && !inQuotes)  ? true : false;
            item += (!comma) ? str[i] : "";
            if(comma || i == str.length-1) {  
                items.push(item);
                item = "";
            }    
        } 
my problem is that if you have one double quotes without a closer in a string
i appreciate the help...
 
     
    