This does not work because String#replace() in javascript is not eager. It only replaces the first occurrence.