Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript remove all newlines

// regex global match for all variants of newlines
/
?
|
/g

// example
let foo = 'bar
bar';
foo = foo.replace(/
?
|
/g, " "); /* replace all newlines with a space */
console.log(foo); /* bar bar */
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #remove #newlines
ADD COMMENT
Topic
Name
2+7 =