Javascript 异常:在for循环控制之后(缺少)
我在运行代码时收到了上述异常 // this function assumes the CSV has no fields with commas, // and strips out all the double quotes function parseCsvResponse(csvString) { var retArray = []; var strLines = csvString.split(/\n/g); var strLineLen = strLines.length; for (var i = 0; i < strLineLen; i++) { var line = strLines[i]; if (line != '') { retArray.push(line.replace(/"/g, "").split(/,/)); } } return retArray; } function populateSheetWithCSV(sheet, csvUrl, user, pw) { // request the CSV! var resp = UrlFetchApp.fetch(csvUrl, { headers: { // use basic auth 'Authorization': 'Basic ' + Utilities.base64Encode(user + ':' + pw, Utilities.Charset.UTF_8) } });Javascript 异常:在for循环控制之后(缺少),javascript,google-apps-script,Javascript,Google Apps Script,我在运行代码时收到了上述异常 // this function assumes the CSV has no fields with commas, // and strips out all the double quotes function parseCsvResponse(csvString) { var retArray = []; var strLines = csvString.split(/\n/g); var strLineLen = strLin
}正如评论员所说,这句话看起来像是罪魁祸首:
retArray.push(line.replace(/“/g,”).split(/,/);
你有一对开放双引号。我想这就是原因
/"/g
你可以用引号括起来,比如:
var myregexp =new RegExp('"','g');
问题:几乎一样。明星吗
引号字符应该成对出现。顺便说一下,还有
实用程序.parseCsv
函数。您不需要自己开发它。
var myregexp =new RegExp('"','g');