title: Regular expression replace $(Key) in text file with value from dictionary
body: <p>I want to do something like this, I have a dictionary with keys and values, and a text file like this:</p>
  
  <pre><code>Hello my name is $(Name) and my favorite movie is $(Movie).
  </code></pre>
  
  <p>I want to read in the file and replace the occurrences of $(...) based on the values in the dictionary, so in this case the dictionary would have a key for Name and Movie.  </p>
  
  <p>How would I go about doing this?  If I parsed through each word, what would be the regular expression to match $(AnyWord), or would it be better to do something like this:</p>
  
  <pre><code>foreach(var word in file)
  {
      if (word.length &gt; 3)
      {
          if (word.substring(0,2)=="$(" &amp;&amp; word.substring(word.length-1)==")")
             Lookup word in dictionary 
      }
  }
  </code></pre>
  
  <p>Thanks</p>