title: Groovy regex when replacing tokens in file
body: <p>I have a text file that has the token "<code>%%#%</code>" located all over the place inside of it. I am trying to write a quick-and-dirty Groovy shell script to replace all instances of "<code>%%#%</code>" with a dollar sign "<code>$</code>".</p>
  
  <p>So far I have:</p>
  
  <pre><code>#!/usr/bin/env groovy
  File f = new File('path/to/my/file.txt')
  f.withWriter{ it &lt;&lt; f.text.replace("%%#%", "$") }
  </code></pre>
  
  <p>But when I run this script, nothing happens (no exceptions <strong>and</strong> no string replacement). I wonder if any of the characters I'm searching for, or the dollar sign itself, is being interpreted as a special char by the regex engine under the hood. In any event, <strong>Where am I going awry?</strong></p>