How to remove all occurrences of a substring from a string with JavaScript

1 Answer

0 votes
var s = "java script java programming java version java";

var re = new RegExp('java', 'g');

s = s.replace(re, '');

document.write(s);
 
     
/*
run:
  
script programming version 
   
*/

 



answered Feb 2, 2019 by avibootz
...