js 将String 转为数组

<script>
s="[[百度文摘, 已启用, 965, 78, 8.08, 0.74358976, 58.0], [百度百科, 已启用, 1860, 1200, 64.52, 0.105, 126.0], [百度博客, 已启用, 6531, 5211, 79.79, 0.109192096, 569.0], [百度MP3, 已启用, 0, 0, 0.0, NaN, 0.0], [百度, 已启用, 0, 0, 0.0, NaN, 0.0], [谷歌, 已启用, 0, 0, 0.0, NaN, 0.0], [腾讯搜搜, 已启用, 0, 0, 0.0, NaN, 0.0]]"
s=s.replace(/\[/g,"['")
s=s.replace(/\]/g,"']")
s=s.replace(/,/g,"','")
s=s.replace(/ \[/g,"[")
s=s.replace(/\]','\[/g,"],[")
s=s.replace(/\['\['/g,"[['")
s=s.replace(/'\]'/g,"']")
arr = eval(s)
for(i=0;i<arr.length;i++)
{
 document.write("<br/>")
 for(j=0;j<arr[i].length;j++)
 document.write(arr[i][j] + " || ")
 }
</script>

你可能感兴趣的:(js,将String,转为数组)