});
 }
 
+function replace() {
+  const from = document.getElementById("replace_from").value;
+  const to = document.getElementById("replace_to").value;
+  dat_lines.forEach((dat_line) => {
+    dat_line.comment = dat_line.comment.replaceAll(from, to);
+    if ('code' in dat_line) {
+      dat_line.code = dat_line.code.replaceAll(from, to);
+    }
+    ['account', 'amount', 'currency'].forEach((key) => {
+      if (key in dat_line.booking_line) {
+        dat_line.booking_line[key] = dat_line.booking_line[key].replaceAll(from, to);
+      }
+    });
+  });
+  taint();
+  update_form();
+}
+
 window.onload = update_form;
 {% endblock %}
 
 {% block content %}
 <form action="/edit_structured/{{id}}" method="POST">
 {{ macros.edit_bar("raw", id) }}
+<input type="button" onclick="replace()" value="replace string">
+from
+<input id="replace_from" />
+to
+<input id="replace_to" />
+<hr />
 <table id="dat_lines">
 </table>
 </form>