You need to make this a global replace. Otherwise you'll only replace the first occurence:

```js
"myid myotherid anotherid".replace( /\s+/, ", #" )
// "myid, #myotherid anotherid"
```