JavaScript replace newline escape sequence with newline
javascript
Solution
`[\\n]` is the set of the characters `\` and `n`. Just take off the brackets:
….replace(/\\n/g, '\n')
In modern JavaScript environments, you can use `String.prototype.replaceAll` (ES2021) instead:
….replaceAll('\\n', '\n')
Problem
I'm looking to replace any occurrences of the string "\n" with the new line character: '\n'. `replace(/[\\n]/g, "\n")` doesn't seem to work. I'm unfamiliar with regex and was wondering if someone could help.