[javascript] How to replace captured groups only?