Replace alias to form phrases Inspired by the C-directive #define.

Challenge

Given one phrase with some alias, and one array with each alias text. Output the initial phrase replacing each alias with its respective text.

An alias is defined by one sharp # followed by its index in the array (the index may start at zero or one). Alias can contains another alias inside its text, and you must resolve all them (maybe recursively). You can assume the alias will never run into an infinite-loop. Alias won't have leading zeroes (#02 is not alias at index 2, it is alias at index 0 followed by the text 2).

You can assume the array will not pass 20 items in length.

You can write a program, or a function or even a #define-it would be nice :)

You can also use another input-method that fits better for your language.

Example

phrase: "#0 &amp; #3"
array: [
    "Programming #1",
    "Puzzles",
    "Code",
    "#2 Golf"
]
output: "Programming Puzzles &amp; Code Golf"


Step by step:

0&gt; "#0 &amp; #3"
1&gt; "Programming #1 &amp; #2 Golf"
2&gt; "Programming Puzzles &amp; Code Golf"


Since this is code-golf, shortest answer in bytes wins!

Another samples

phrase: "#0!"
array: [
    "We are #1",
    "#2",
    "#3",
    "#4 !",
    "graduating"
]
output: "We are graduating !!"




phrase: "##0#1#0#21#3#4"
array: [
    "a",
    "m",
    "z",
    "n",
    "g"
]
output: "#amaz1ng"




phrase: "##1#23"
array: [
    "WEIRD",
    "0 C",
    "AS"
]
output: "WEIRD CAS3"




phrase: "#1#7#6y#4#7#10s#7b#11#0#0#11r#7#0h#6#5#2#5#9#4."
array: [
    "t",
    "#12#3",
    "#11ga#3",
    "#0#10v#11",
    "#0h#10#8g",
    "#7#8",
    "a#8",
    " ",
    "n",
    "o",
    "i",
    "e",
    "P#9s#10"
]
output: "Positive anything is better than negative nothing."


The examples above used Array with index starting at zero.
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;