Seems to work for me:
var str = "something //here is something more"; console.log(str.replace(new RegExp("\/\/.*$","g"), ""));
Also note that the regular expression literal /\/\/.*$/g equivalent to the regular expression generated by your use of the RegExp object. In this case, using the literal is less verbose and may be preferable.
Are you reassigning the return value of replace to pathCode ?
pathCode = pathCode.replace(new RegExp("\/\/.*$","g"), "");
replace does not change the string object it is working on. Instead, it returns a value.
Vivin paliath
source share