delete specific character from 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: javascript remove specific character from string

var newString = oldString.replaceAll("character/string goes here", "");

// Example
var oldString = "Hello World!";
var newString = oldString.replaceAll("o", "");
console.log(newString);
// Prints 'Hell Wrld!' to console.

Example 3: js remove string from string

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

Example 4: javascript remove character from string

mystring.replace(/r/g, '')

Tags:

Php Example