Try it with a global match instead of exec.
Exec finds one match at a time, so you can do something to the matched text.
If you are just collecting them, a match will get them all at once.
var mystring = "Going to the #museum and then to the #gym";
var mypattern = /(#[a-zA-Z0-9]+)/g;
var myresult= mystring.match(mypattern);
/* returned value: ['#museum','#gym'] */
By the way, # is called the 'octothorp' , from a word meaning eight-points.