You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//? This program replace all line breaks (newline character) in a string with a specific string or character,you can use the replace() method with a regular expression.
function replaceLineBreaks(str, char, replacement) {
let regex = new RegExp(char, "g");
console.log(regex);
let modified = str.replace(regex, replacement);
console.log(modified);
}
replaceLineBreaks("Hello,\nWorld!\nThis is new line", "\n", "-");