Replace alias to form phrases
JavaScript (ES6) 58

Recursive function

f=(s,h,r=s.replace(/#(1?\d)/g,(_,x)=&gt;h[x]))=&gt;r==s?r:f(r,h)


Test



f=(s,h,r=s.replace(/#(1?\d)/g,(_,x)=&gt;h[x]))=&gt;r==s?r:f(r,h)

// Version without default parameters, same length but using a global
// f=(s,h)=&gt;(r=s.replace(/#(1?\d)/g,(_,x)=&gt;h[x]))==s?r:f(r,h)

console.log=x=&gt;O.textContent+=x+'\n'

;[
  ['##1#23',['WEIRD','0 C','AS']],
  ["#0!",["We are #1","#2","#3","#4 !","graduating"]],
  ["##0#1#0#21#3#4",["a","m","z","n","g"]],
  ["##0#1#0#21#13#4",["a","m","z","","g","","","","","","","","","n"]],
  ["#1#7#6y#4#7#10s#7b#11#0#0#11r#7#0h#6#5#2#5#9#4.",
    ["t","#12#3","#11ga#3","#0#10v#11","#0h#10#8g","#7#8","a#8"," ","n","o","i","e","P#9s#10"]
  ],
  ["#0 &amp; #3",["Programming #1","Puzzles","Code","#2 Golf"]]
].forEach(t=&gt;{
  var a=t[0],b=t[1]
  console.log(a+' ['+b+']\n -&gt; '+f(a,b))
})
&lt;pre id=O&gt;&lt;/pre&gt;