delete specific word in string javascript code example

Example 1: javascript remove line breaks from string

var stringWithLineBreaks = `
O boy 
I've got 
Breaks
`;
var stringWithoutLineBreaks = stringWithLineBreaks.replace(/(\r\n|\n|\r)/gm, "");//remove those line breaks

Example 2: How to remove text from a string in javscript

var ret = "data-123".replace('data-','');
console.log(ret);   //prints: 123

Example 3: how to remove a text by javascript

var ret = "data-123".replace('data-','');

Example 4: js remove ta contin word

$('div:contains("word2")').remove();