79236059

Date: 2024-11-29 06:47:36
Score: 1
Natty:
Report link

I use this construct a lot on a web server when I want to reuse a console.error() (or console.log) string in HTML output:

const err_msg = 'line 1\nline 2\nline3'

console.error(err_msg)

html_err_msg = err_msg.replace(/\n/g, '<BR>')

...then embed html_err_msg in the web page you are serving up, and voila, Bob's your uncle, and he can see then lines not all run together in his browser. The other answers explain the (g)lobal modifier on the regex.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: monist