Remove line breaks with JavaScript
var stringWithLineBreaks = `
O boy
I've got
Breaks
`;
var stringWithoutLineBreaks = stringWithLineBreaks.replace(/(\r\n|\n|\r)/gm, "");//remove those line breaksString.replace(/(\r\n|\n|\r)/gm," ")let multilineString = `My
text\r1\r\n2\n3\n\r4
is
here`;
let htmlText = multilineString.replace(/(\r\n|\n\r|\r|\n)/g, '<br>');
console.log('Multiline string: ' + multilineString);
console.log('HTML text: ' + htmlText);
Also in JavaScript:
- get top items from json object
- react conditional class
- mongoose find multiple conditions
- how to add script before </body> in magento 2
- html select multiple selected values
- google sign in in firebase react
- regular expression flags
- javascript create array of object keys
- if statement javascript
- react detect finger
- datepicker range npm reactjs
- error: Error: Unable to resolve module `crypto` from `node_modules\crypto-js\core.js`: crypto could not be found within the project.
- shopware 5 subscribe to theme collect javascript
- npm i material ui
- atari breakout
- tip in js
- react sagas state
- get current time in js
- how to find out what a string ends with in javascript
- react google ap
- scrollbar position
- flutter intl currency
- create link and click javascript
- javascript automatic click