Replace All Line Breaks Using RegEx
JavaScript
xxxxxxxxxx
const string = `I am Learning JavaScript.
JavaScript is fun.
JavaScript is easy.`;
const result = string.replace(/(\r\n|\r|\n)/g, '<br>');
console.log(result);
I am Learning JavaScript.<br>JavaScript is fun.<br>JavaScript is easy.
Replace All Line Breaks Using Built-in Methods
JavaScript
xxxxxxxxxx
const string = `I am Learning JavaScript.
JavaScript is fun.
JavaScript is easy.`;
const result = string.split('\n').join('<br>');
console.log(result);
I am Learning JavaScript.<br>JavaScript is fun.<br>JavaScript is easy.
Linux - How to Install anc-api-tools
Linux - How to Install curvedns
Linux - How to Install zenmap
Python - Check if a Number is Positive, Negative or 0
C - Count Number of Digits in an Integer
C++ - Check Whether a Number is Prime or Not
C - Find Largest Number Using Dynamic Memory Allocation
C++ - Check Leap Year
JavaScript - Check Whether a String Starts and Ends With Certain Characters
Kotlin - Reverse a Number
Linux - How to Install zstd
C++ - Find Quotient and Remainder
Linux - How to Install xbitmaps
Kotlin - Round a Number to n Decimal Places
Python - Writing Excel (XLSX) Files
Java - Reverse a Number
Kotlin - Find Factorial of a Number
Java - Create Pyramid and Pattern
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month