.replaceの履歴

hoge.replace("置換前","置換後);
だと「置換前」が2回以上出てきても最初の1つ目しか処理してくれないので注意

<script type="text/javascript">
var data = "";
var item = "";
function replaceAll(expression, org, dest){  //http://www.syboos.jp/webjs/doc/string-replace-and-replaceall.html
    return expression.split(org).join(dest);
}
for(var i = 0;i<10000;i++){
  if((typeof(localStorage[i]) == "undefined")||(localStorage[i] == "undefined")||(localStorage[i] == "")){
  }else{
    item = replaceAll(localStorage[i],"\n","\\n");
    item = replaceAll(item,"\'","\\'");
    data += "localStorage["+i+"] = '";
    data += item;
    data += "';";
  }
  $("#data").html(data);
}
</script>