How to tell the difference between \n in a string and a newline?

Try

let lines = file.split(/(?<!:)\n/)

But it would be best to correct the code and remove non valid property characters from your property names, then you would not have to patch the issue.

Just for info

const foo = file.replace( ":\n", ":::")

will only replace first occurance.
it should be

const foo = file.replace( /:\n/g, ":::")

for multiple replaces.

2 Likes