曾嘗試過各種東西我怎樣才能找到一個特定的指數在一個數組的長度
split[6].length
String.split[6].length
沿着這些線路沒有成功拿到最後一個此錯誤消息......
的ReferenceError:「字符串「未定義。
嗨感謝所有的答覆,最後我創建了一個基於原始數組索引的數組,然後查詢其長度。正如你所看到的,我無法從輸入字符串中刪除單引號和雙引號。新的JavaScript和它使我有點瘋狂大聲笑。
// Loop through all the input messages
for (var i = 0; i < input.length; i++) {
var next = output.append(input[i]);
// Get the body of the current input message
var body = input[i].text;
// Set the body
next.text = body ;
next.text.replace(/\'/g, "'");
next.text.replace(/\"/g, """);
//replace(/['"]/g,'');
// Set a property
var split = next.text.split(",");
var array1 = split[5];
var array2 = split[2];
next.setProperty("aaaLength", split.length);
next.setProperty("aaaSplitValue", split.length);
next.setProperty("aaaArray1Value", split.length);
next.setProperty("aaaArray2Value", split.length);
if (next.getProperty("BaseFilename")=="name"){
next.text.replace(/\'/g, "'");
next.text.replace(/\"/g, """);
//replace(/['"]/g,'');
if(split.length>10){
next.setProperty("FullFilename","nameError"+i);
next.setProperty("BaseFilename","nameError"+i);
next.setProperty("Suffix",".err");
}
if(array1.length>10){
next.setProperty("FullFilename","nameSnameSuffixError"+i);
next.setProperty("BaseFilename","nameSnameSuffixError"+i);
next.setProperty("Suffix",".err");
}
}
你是什麼意思「特定指數的長度」?你的意思是存儲在該索引處的字符串的長度? – 2011-04-12 02:45:04
請編輯您的問題,以在您的示例中包含「拆分」對象的詳細信息。 – maerics 2011-04-12 02:47:31
我們需要更多的周邊代碼。什麼是'分裂'應該是? – deceze 2011-04-12 02:47:40