Awk access to dictionary in gsub
<p>I have the next code and I want to access the position "\1" which matches in the text like (([0-9]+)) in the dictionary d that I create in the <code>BEGIN</code> block.
The problem is that in <code>gensub</code>, d[["\1"]] prints this literally, instead of the dictionary word.</p>

<p>How could I achieve it?</p>

<pre><code>awk 'BEGIN {
  while (getline &lt; "dictionary")
     d["(("i++"))"]=$0
}
{
for (i=1; i&lt;=NF; i++)
  $i=tolower($i)
}
{
print gensub(/(\(\([0-9]+\)\))/, d["\\1"], "g")
}' fileToReplace.log
</code></pre>

<p>Example of fileToReplace.log:</p>

<pre><code>|||

I want to go to d'((2)) from ((1)

I want to go

To d'(1))

From (4)

|||
</code></pre>

<p>Example of dictionary:</p>

<pre><code>UK
Dublin
Madrid
Ireland
</code></pre>

<p>And the expected output is:</p>

<pre><code>|||

I want to go to d'Dublin from UK

I want to go

To d'UK

From Ireland

|||
</code></pre>

<p>Basically what I need is to match the number inside any combination of parens and replace this combination (all the parens and the number) with its corresponding position in the dictionary</p>