var str = "Artist - track (Ori Mix) ## 1:4:32", reg = /[^\s#][^#]+[^\s#]/g; alert( JSON.stringify(str.match(reg))); str = "Artist - track (Ori Mix)"; alert( JSON.stringify(str.match(reg)));