var k = []; $('textarea[name^=img_]').each(function () { k.push([this.name, this.value.replace(/\n/g, "{{n}}").replace(/"/g, "'")]); }); k = k.join("||"); alert('"' + k + '"');