javascript remove all newlines
var stringWithLineBreaks = `
O boy
I've got
Breaks
`;
var stringWithoutLineBreaks = stringWithLineBreaks.replace(/(\r\n|\n|\r)/gm, "");//remove those line breaks// regex global match for all variants of newlines
/\r?\n|\r/g
// example
let foo = 'bar\nbar';
foo = foo.replace(/\r?\n|\r/g, " "); /* replace all newlines with a space */
console.log(foo); /* bar bar */
Also in JavaScript:
- hide warnings in expo app
- ngingx proxy express get real ip
- create and append element in javascript
- midpoint formula javascript
- send mail node.js
- how to do a classname variable and string react
- chart.js on hover and onclick event
- javascript check if is array
- showing an image in react js
- agregar año en javascript
- access css property using javascript
- cypress set viewport for all test cases
- react google maps for development purposes only
- react native cover image in parent view
- print to console without newline nodejs
- add firebase javascript
- jquery select element with data
- aba translate js
- number to binary javascript
- arraylist to json array
- how to set background colour i js inline stylel
- does json only support ascii
- how to use if else statement in javascript
- add id jquery