I'm pulling in some data from an api and console.log in chrome:
Chrome prints it like asdföklajsd↵New line!
I would like to replace the ↵ character with a <br />
using replace
in javascript. How do I reference that character?
It is abbreviation of the phrase Virtual Machine. In the Chrome JavaScript engine (called V8) each script has its own script ID. Sometimes V8 has no information about the file name of a script, for example in the case of an eval .
Open Chrome, press Ctrl+Shift+j and it opens the JavaScript console where you can write and test your code.
Use the short cut Ctrl + L to clear the console. Use the clear log button on the top left corner of the chrome dev tools console to clear the console. On MacOS you can use Command + K button.
It's a return character.
Try replacing them like this:
myString = myString.replace(/(\r\n|\n|\r)/gm, "<br />");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With