You also need to make sure that you are using
.replace() on the proper data type. It also seems like you are trying to replace a newline character with another newline character, which wouldn’t have any effect.
for those (like me) too lazy to learn regex for now, you can use split-join.
example, used in html txt parsing to get text from tag A to tag Z excluding all occurrences of tag X inside.
const cut=(txt,a,z,x)=>cutter((txt.split(a,2).pop().split(z,2).shift()), x);
but anyway, i’m going to start learning regex one day…